-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathaction.yml
More file actions
104 lines (90 loc) · 3.14 KB
/
action.yml
File metadata and controls
104 lines (90 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: 'GitHub Space Shooter'
description: 'Transform your GitHub contribution graph into a space shooter game GIF'
author: 'zane'
branding:
icon: 'navigation-2'
color: 'black'
inputs:
github-token:
description: 'GitHub token for fetching contribution data (usually secrets.GITHUB_TOKEN)'
required: true
username:
description: 'GitHub username to generate game for (defaults to repository owner)'
required: false
default: ${{ github.repository_owner }}
output-path:
description: 'Path where the GIF should be saved'
required: false
default: 'gh-space-shooter.gif'
strategy:
description: 'Enemy attack strategy (column, row, or random)'
required: false
default: 'random'
fps:
description: 'Frames per second for the animation (default: 40)'
required: false
default: '40'
no-amend:
description: 'Disable amending previous commits (always create new commits)'
required: false
default: 'false'
commit-message:
description: 'Commit message for the GIF update'
required: false
default: 'Update space shooter game GIF'
outputs:
output-file:
description: 'Path to the generated output file (GIF or WebP)'
value: ${{ steps.generate.outputs.output-file }}
runs:
using: 'composite'
steps:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install gh-space-shooter
shell: bash
run: |
python -m pip install --upgrade pip
pip install gh-space-shooter
- name: Generate game
id: generate
shell: bash
env:
GH_TOKEN: ${{ inputs.github-token }}
run: |
gh-space-shooter ${{ inputs.username }} \
--output ${{ inputs.output-path }} \
--strategy ${{ inputs.strategy }} \
--fps ${{ inputs.fps }}
echo "output-file=${{ inputs.output-path }}" >> $GITHUB_OUTPUT
- name: Commit and push
shell: bash
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
OUTPUT_PATH="${{ inputs.output-path }}"
COMMIT_MSG="${{ inputs.commit-message }}"
NO_AMEND="${{ inputs.no-amend }}"
git add "$OUTPUT_PATH"
SHOULD_AMEND="false"
if [ "$NO_AMEND" != "true" ]; then
git log -1 --oneline
LAST_MSG=$(git log -1 --pretty=%s 2>/dev/null || echo "")
LAST_FILES=$(git log -1 --name-only --pretty=format: 2>/dev/null | grep -v '^$' || echo "")
echo "LAST_MSG: ${LAST_MSG} | COMMIT_MSG: ${COMMIT_MSG}"
echo "LAST_FILES: ${LAST_FILES} | OUTPUT_PATH: ${OUTPUT_PATH}"
if [ "$LAST_MSG" = "$COMMIT_MSG" ] && [ "$LAST_FILES" = "$OUTPUT_PATH" ]; then
SHOULD_AMEND="true"
fi
fi
if [ "$SHOULD_AMEND" = "true" ]; then
echo "Amending previous commit (same message and file)"
git commit --amend --no-edit
git push --force-with-lease
else
echo "Creating new commit"
git diff --staged --quiet || git commit -m "$COMMIT_MSG"
git push
fi