Commit 81dba72
authored
fix(gh-cache): Get remote changes before pushing, to avoid concurrent write failures (#339)
If two concurrent jobs attempt to push to the `gh-cache` branch at the
same time, `git` fails with an error like this:
```
[gh-cache] Save artifact: cached_findings-main.json
1 file changed, 1 insertion(+), 1 deletion(-)
Committed 'cached_findings-main.json' to 'gh-cache' branch
To https://github.com/github-community-projects/continuous-ai-for-accessibility-scanner
! [rejected] gh-cache -> gh-cache (fetch first)
error: failed to push some refs to 'https://github.com/github-community-projects/continuous-ai-for-accessibility-scanner'
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
```
This happens even in cases where the remote’s changes and the local
changes don’t conflict, e.g. if two different files were updated.
This PR fixes the issue by fetching and rebasing[^1] before pushing.
[^1]: Unless the `gh-cache` branch doesn’t existing on the remote. If
this is the case, the commands are skipped, because a. they are
unnecessary and b. they would fail.1 file changed
+5
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
| |||
0 commit comments