Simplify and fix GitHub workflow push to main
Instead of fetching and checking out the formatted commit before pushing,
directly push the formatted commit SHA to main. This simplifies the workflow
and is more reliable.
Add missing outputs section to workflow_call definition in formatting.yml
to properly expose the commit SHA to the calling workflow.
Co-Authored-By: sketch <hello@sketch.dev>
diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml
index 5cc77e3..2920665 100644
--- a/.github/workflows/formatting.yml
+++ b/.github/workflows/formatting.yml
@@ -7,6 +7,10 @@
required: false
type: boolean
default: false
+ outputs:
+ commit_sha:
+ description: "The SHA of the commit with formatting fixes"
+ value: ${{ jobs.formatting.outputs.commit_sha }}
push:
branches-ignore:
- "queue-main-**"
diff --git a/.github/workflows/queue-main.yml b/.github/workflows/queue-main.yml
index 9f66b42..5f532a4 100644
--- a/.github/workflows/queue-main.yml
+++ b/.github/workflows/queue-main.yml
@@ -48,13 +48,13 @@
git config --global user.name "GitHub Actions Bot"
git config --global user.email "actions@github.com"
- # Check if we have a formatting commit SHA
+ # Use the formatted commit SHA if available, otherwise use HEAD
+ COMMIT_TO_PUSH="HEAD"
if [[ "${{ needs.formatting.outputs.commit_sha }}" != "" ]]; then
echo "Using formatted commit: ${{ needs.formatting.outputs.commit_sha }}"
- git fetch origin ${{ needs.formatting.outputs.commit_sha }}
- git checkout ${{ needs.formatting.outputs.commit_sha }}
+ COMMIT_TO_PUSH="${{ needs.formatting.outputs.commit_sha }}"
fi
- git push https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/boldsoftware/sketch.git HEAD:main
+ git push https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/boldsoftware/sketch.git "${COMMIT_TO_PUSH}":main
env:
GITHUB_TOKEN: ${{ github.token }}