ci: automate pinning of in-repo versions at release time

This commit is contained in:
Damien Retzinger
2026-04-27 19:10:34 -04:00
parent e1a8a81488
commit 1f4db0036c
+17 -10
View File
@@ -5,6 +5,9 @@ on:
branches: branches:
- main - main
env:
RELEASE_BRANCH: release-please--branches--main--components--github-actions-magento2
jobs: jobs:
release-please: release-please:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -17,28 +20,32 @@ jobs:
token: ${{ secrets.GRAYCORE_GITHUB_TOKEN }} token: ${{ secrets.GRAYCORE_GITHUB_TOKEN }}
- name: Checkout release PR branch - name: Checkout release PR branch
if: steps.release.outputs.pr
uses: actions/checkout@v6 uses: actions/checkout@v6
with: with:
ref: ${{ fromJSON(steps.release.outputs.pr).headBranchName }} ref: ${{ env.RELEASE_BRANCH }}
token: ${{ secrets.GRAYCORE_GITHUB_TOKEN }} token: ${{ secrets.GRAYBOT_PIN_BACK_PAT }}
- name: Pin refs on release PR branch - name: Pin refs on release PR branch
if: steps.release.outputs.pr id: pin-refs
env:
GRAYBOT_GPG_KEY: ${{ secrets.GRAYBOT_GPG_KEY }}
run: | run: |
VERSION="v$(jq -r '."."' .release-please-manifest.json)" VERSION="v$(jq -r '."."' .release-please-manifest.json)"
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
sed -i "s|uses: graycoreio/github-actions-magento2/\([^@]*\)@main|uses: graycoreio/github-actions-magento2/\1@${VERSION}|g" \ sed -i "s|uses: graycoreio/github-actions-magento2/\([^@]*\)@main|uses: graycoreio/github-actions-magento2/\1@${VERSION}|g" \
*/action.yml \ */action.yml \
$(find .github/workflows \( -name "*.yml" -o -name "*.yaml" \) ! -name "release-*") $(find .github/workflows \( -name "*.yml" -o -name "*.yaml" \) ! -name "release-*")
if git diff --quiet; then if git diff --quiet; then
echo "No changes — refs already pinned to ${VERSION}" echo "HAS_CHANGES=false" >> $GITHUB_OUTPUT
exit 0 else
echo "HAS_CHANGES=true" >> $GITHUB_OUTPUT
fi fi
- name: Commit pinned refs
if: steps.pin-refs.outputs.HAS_CHANGES == 'true'
env:
GRAYBOT_GPG_KEY: ${{ secrets.GRAYBOT_GPG_KEY }}
run: |
echo "$GRAYBOT_GPG_KEY" | gpg --batch --import echo "$GRAYBOT_GPG_KEY" | gpg --batch --import
export GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d/ -f2) export GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d/ -f2)
git config --global user.signingkey $GPG_KEY_ID git config --global user.signingkey $GPG_KEY_ID
@@ -46,5 +53,5 @@ jobs:
git config --global user.email "automation@graycore.io" git config --global user.email "automation@graycore.io"
git config --global user.name "Beep Boop" git config --global user.name "Beep Boop"
git add . git add .
git commit -m "chore: pin internal action refs to ${VERSION}" git commit -m "chore: pin internal action refs to ${{ steps.pin-refs.outputs.VERSION }}"
git push origin ${{ fromJSON(steps.release.outputs.pr).headBranchName }} git push origin ${{ env.RELEASE_BRANCH }}