Skip to content

Commit f8fd4f3

Browse files
committed
CI: Push wasm commit on changes only
When rerunning the deploy wasm CI, previously successful jobs may fail due to a reproducible error: nothing to commit, working tree clean Error: Process completed with exit code 1. This occurs because the successful deployment has already committed the changes. To prevent this, the workflow should check whether there are any staged changes before attempting to commit. If there’s nothing to commit, skip the push step. Otherwise, proceed with committing and pushing the new changes.
1 parent b6aa3ca commit f8fd4f3

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

.github/workflows/deploy-wasm.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,22 @@ jobs:
9292
mv /tmp/rv32emu-system-demo/rv32emu.wasm ./system
9393
mv /tmp/rv32emu-system-demo/rv32emu.worker.js ./system
9494
- name: Commit files
95+
id: commit
9596
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
9697
github.event_name == 'workflow_dispatch' ||
9798
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
9899
run: |
99100
git config --local user.email "github-actions[bot]@users.noreply.github.com"
100101
git config --local user.name "github-actions[bot]"
101102
git add system/
102-
git commit -m "Add changes to system emulation"
103+
if git diff --cached --quiet; then
104+
echo "committed=false" >> $GITHUB_OUTPUT
105+
else
106+
git commit -m "Add changes to system emulation"
107+
echo "committed=true" >> $GITHUB_OUTPUT
108+
fi
103109
- name: Push changes
104-
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
105-
github.event_name == 'workflow_dispatch' ||
106-
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
110+
if: steps.commit.outputs.committed == 'true'
107111
uses: ad-m/github-push-action@master
108112
with:
109113
repository: sysprog21/rv32emu-demo
@@ -184,18 +188,22 @@ jobs:
184188
mv /tmp/rv32emu-demo/rv32emu.wasm .
185189
mv /tmp/rv32emu-demo/rv32emu.worker.js .
186190
- name: Commit files
191+
id: commit
187192
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
188193
github.event_name == 'workflow_dispatch' ||
189194
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
190195
run: |
191196
git config --local user.email "github-actions[bot]@users.noreply.github.com"
192197
git config --local user.name "github-actions[bot]"
193198
git add --all
194-
git commit -m "Add changes to user emulation"
199+
if git diff --cached --quiet; then
200+
echo "committed=false" >> $GITHUB_OUTPUT
201+
else
202+
git commit -m "Add changes to user emulation"
203+
echo "committed=true" >> $GITHUB_OUTPUT
204+
fi
195205
- name: Push changes
196-
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
197-
github.event_name == 'workflow_dispatch' ||
198-
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
206+
if: steps.commit.outputs.committed == 'true'
199207
uses: ad-m/github-push-action@master
200208
with:
201209
repository: sysprog21/rv32emu-demo

0 commit comments

Comments
 (0)