File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change 33on :
44 push :
55
6+ permissions :
7+ contents : write
8+
69
710jobs :
811 pr-checks :
@@ -115,4 +118,26 @@ jobs:
115118 message : " ci: update artifacts [skip ci]"
116119 skip-empty : true
117120
118- - run : git push origin || echo "nothing to push"
121+ - name : Push artifact commit
122+ shell : bash
123+ run : |
124+ set -euo pipefail
125+
126+ BRANCH=main
127+ git fetch origin "$BRANCH"
128+
129+ LOCAL_HEAD="$(git rev-parse HEAD)"
130+ REMOTE_HEAD="$(git rev-parse "origin/$BRANCH")"
131+
132+ if [ "$LOCAL_HEAD" = "$REMOTE_HEAD" ]; then
133+ echo "No new commit to push."
134+ exit 0
135+ fi
136+
137+ # Prevent pushing stale dist from an outdated run.
138+ if ! git merge-base --is-ancestor "$REMOTE_HEAD" "$LOCAL_HEAD"; then
139+ echo "::error::Remote $BRANCH moved. This run is outdated; not pushing artifacts."
140+ exit 1
141+ fi
142+
143+ git push --porcelain origin "HEAD:$BRANCH"
You can’t perform that action at this time.
0 commit comments