|
| 1 | +# This workflow automatically updates ShapeEngine/gamecontrollerdb.txt monthly. |
| 2 | +# Steps: |
| 3 | +# 1. Downloads the latest gamecontrollerdb.txt from SDL_GameControllerDB. |
| 4 | +# 2. Stages the file and checks for changes. |
| 5 | +# 3. If changes are detected: |
| 6 | +# - Creates a new branch |
| 7 | +# - Commits the update |
| 8 | +# - Pushes the branch |
| 9 | +# - Opens a pull request |
| 10 | +# 4. If no changes, no branch/commit/PR is created. |
| 11 | +# The workflow is triggered monthly and can be run manually. |
| 12 | + |
1 | 13 | name: Monthly Update gamecontrollerdb.txt |
2 | 14 |
|
3 | 15 | permissions: |
@@ -25,22 +37,43 @@ jobs: |
25 | 37 | git config --local user.email "github-actions[bot]@users.noreply.github.com" |
26 | 38 | git config --local user.name "github-actions[bot]" |
27 | 39 |
|
| 40 | + - name: Stage gamecontrollerdb.txt |
| 41 | + run: | |
| 42 | + git add ShapeEngine/gamecontrollerdb.txt |
| 43 | +
|
| 44 | + - name: Check for changes |
| 45 | + id: check_changes |
| 46 | + run: | |
| 47 | + if git diff --cached --quiet; then |
| 48 | + echo "changes_made=false" >> $GITHUB_OUTPUT |
| 49 | + else |
| 50 | + echo "changes_made=true" >> $GITHUB_OUTPUT |
| 51 | + fi |
| 52 | +
|
| 53 | +
|
28 | 54 | - name: Create update branch |
| 55 | + if: steps.check_changes.outputs.changes_made == 'true' |
29 | 56 | run: | |
30 | | - BRANCH="update-controllerdb-$(date +'%Y%m%d')" |
| 57 | + if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then |
| 58 | + BRANCH="update-controllerdb-$(date +'%d%m%Y')-manual" |
| 59 | + else |
| 60 | + BRANCH="update-controllerdb-$(date +'%d%m%Y')" |
| 61 | + fi |
31 | 62 | git checkout -b $BRANCH |
32 | 63 | echo "BRANCH=$BRANCH" >> $GITHUB_ENV |
33 | 64 |
|
34 | 65 | - name: Commit changes |
| 66 | + if: steps.check_changes.outputs.changes_made == 'true' |
35 | 67 | run: | |
36 | | - git add ShapeEngine/gamecontrollerdb.txt |
37 | | - git diff --cached --quiet || git commit -m "Automated monthly update of gamecontrollerdb.txt" |
| 68 | + git commit -m "Automated monthly update of gamecontrollerdb.txt" |
38 | 69 |
|
39 | 70 | - name: Push branch |
| 71 | + if: steps.check_changes.outputs.changes_made == 'true' |
40 | 72 | run: | |
41 | 73 | git push origin $BRANCH |
42 | 74 |
|
43 | 75 | - name: Create Pull Request |
| 76 | + if: steps.check_changes.outputs.changes_made == 'true' |
44 | 77 | uses: peter-evans/create-pull-request@v5 |
45 | 78 | with: |
46 | 79 | token: ${{ secrets.GITHUB_TOKEN }} |
|
0 commit comments