|
12 | 12 | required: false
|
13 | 13 |
|
14 | 14 | # These must be declared, but they are unused and ignored.
|
15 |
| - # TODO: Get 'repo' and 'gitref' from the PR on other workflows, so we can remove these. |
| 15 | + # TODO: Infer 'repo' and 'gitref' from PR number on other workflows, so we can remove these. |
16 | 16 | repo:
|
17 | 17 | description: "Repo (Ignored)"
|
18 | 18 | required: false
|
|
53 | 53 | # Without this we would be forever waiting on required checks to pass.
|
54 | 54 | token: ${{ secrets.GH_PAT_APPROVINGTON_OCTAVIA }}
|
55 | 55 |
|
56 |
| - # - name: Checkout PR (${{ github.event.inputs.pr }}) |
57 |
| - # uses: dawidd6/action-checkout-pr@v1 |
58 |
| - # with: |
59 |
| - # pr: ${{ github.event.inputs.pr }} |
60 |
| - |
61 | 56 | - name: Append comment with job run link
|
62 |
| - # If not comment-id is provided, this will create a new |
| 57 | + # If comment-id is not provided, this will create a new |
63 | 58 | # comment with the job run link.
|
64 | 59 | id: first-comment-action
|
65 | 60 | uses: peter-evans/create-or-update-comment@v4
|
@@ -89,29 +84,44 @@ jobs:
|
89 | 84 | - name: Remove any files that have been gitignored
|
90 | 85 | run: git ls-files -i -c --exclude-from=.gitignore | xargs -r git rm --cached
|
91 | 86 |
|
92 |
| - - name: Commit Formatting Changes (PR) |
| 87 | + # Check for changes in git |
| 88 | + |
| 89 | + - name: Check for changes |
| 90 | + id: git-diff |
| 91 | + run: | |
| 92 | + git diff --quiet && echo "No changes to commit" || echo "::set-output name=changes::true" |
| 93 | + shell: bash |
| 94 | + |
| 95 | + # Commit changes (if any) |
| 96 | + |
| 97 | + - name: Commit changes |
93 | 98 | id: commit-step
|
94 |
| - uses: stefanzweifel/git-auto-commit-action@v5 |
95 |
| - # Don't commit if we're on master |
96 |
| - if: github.ref != 'refs/heads/master' |
97 |
| - with: |
98 |
| - repository: ${{ steps.job-vars.outputs.repo }} |
99 |
| - commit_message: "chore: format code" |
100 |
| - commit_user_name: Octavia Squidington III |
101 |
| - commit_user_email: [email protected] |
| 99 | + if: steps.git-diff.outputs.changes == 'true' |
| 100 | + run: | |
| 101 | + git config --global user.name "Octavia Squidington III" |
| 102 | + git config --global user.email "[email protected]" |
| 103 | + git add . |
| 104 | + git commit -m "chore: auto-fix lint and format issues" |
| 105 | + echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT |
| 106 | +
|
| 107 | + - name: Push changes to '(${{ steps.job-vars.outputs.repo }})' |
| 108 | + if: steps.git-diff.outputs.changes == 'true' |
| 109 | + run: | |
| 110 | + git remote add contributor https://github.com/${{ steps.job-vars.outputs.repo }}.git |
| 111 | + git push contributor HEAD:${{ steps.job-vars.outputs.branch }} |
102 | 112 |
|
103 | 113 | - name: Append success comment
|
104 | 114 | uses: peter-evans/create-or-update-comment@v4
|
105 |
| - if: steps.commit-step.outputs.changes_detected == 'true' |
| 115 | + if: steps.git-diff.outputs.changes == 'true' |
106 | 116 | with:
|
107 | 117 | comment-id: ${{ steps.first-comment-action.outputs.comment-id }}
|
108 | 118 | reactions: hooray
|
109 | 119 | body: |
|
110 |
| - > ✅ Changes applied successfully. (${{ steps.commit-step.outputs.commit_hash }}) |
| 120 | + > ✅ Changes applied successfully. (${{ steps.commit-step.outputs.sha }}) |
111 | 121 |
|
112 | 122 | - name: Append success comment (no-op)
|
113 | 123 | uses: peter-evans/create-or-update-comment@v4
|
114 |
| - if: steps.commit-step.outputs.changes_detected != 'true' |
| 124 | + if: steps.git-diff.outputs.changes != 'true' |
115 | 125 | with:
|
116 | 126 | comment-id: ${{ steps.first-comment-action.outputs.comment-id }}
|
117 | 127 | reactions: "+1"
|
|
0 commit comments