Auto-patch upstream runner tags #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto-patch upstream runner tags | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' # daily at 06:00 UTC | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| env: | |
| # Commit that adds Bitrise cache integration (on top of v2.331.0). | |
| # To update: push a new patch commit and replace this hash. | |
| PATCH_COMMIT: b799451657f1666717f6661ca8079da95ade7922 | |
| jobs: | |
| patch-and-tag: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo with full history and tags | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Fetch patch commit and upstream tags | |
| run: | | |
| # Fetch the branch that contains our patch commit | |
| git fetch origin bitrise-v2.331.0 | |
| # Fetch all upstream tags | |
| git remote add upstream https://github.com/actions/runner.git | |
| git fetch upstream 'refs/tags/*:refs/tags/upstream/*' | |
| - name: Find and patch new tags | |
| run: | | |
| git config user.name "bitrise-bot" | |
| git config user.email "bot@bitrise.io" | |
| # Collect all upstream v* tags | |
| UPSTREAM_TAGS=$(git tag -l 'upstream/v*' | sed 's|^upstream/||' | sort -V) | |
| PATCHED=0 | |
| FAILED=0 | |
| SKIPPED=0 | |
| for TAG in $UPSTREAM_TAGS; do | |
| PATCHED_TAG="${TAG}-bitrise" | |
| # Check if we already have this patched tag | |
| if git rev-parse "refs/tags/${PATCHED_TAG}" >/dev/null 2>&1; then | |
| SKIPPED=$((SKIPPED + 1)) | |
| continue | |
| fi | |
| echo "::group::Patching ${TAG} -> ${PATCHED_TAG}" | |
| # Checkout the upstream tag in a detached HEAD | |
| git checkout "upstream/${TAG}" --detach 2>&1 | |
| # Cherry-pick the Bitrise cache integration commit | |
| if git cherry-pick --no-commit "${PATCH_COMMIT}" && \ | |
| git commit -m "Bitrise cache integration"; then | |
| git tag "${PATCHED_TAG}" | |
| if git push origin "${PATCHED_TAG}"; then | |
| echo "Successfully tagged and pushed ${PATCHED_TAG}" | |
| PATCHED=$((PATCHED + 1)) | |
| else | |
| echo "::warning::Push failed for ${PATCHED_TAG}" | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| else | |
| echo "::warning::Cherry-pick failed on ${TAG} — manual intervention required" | |
| git cherry-pick --abort || true | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| echo "::endgroup::" | |
| done | |
| echo "" | |
| echo "=== Summary ===" | |
| echo "Patched: ${PATCHED}" | |
| echo "Skipped (already exist): ${SKIPPED}" | |
| echo "Failed: ${FAILED}" | |
| if [ "${FAILED}" -gt 0 ]; then | |
| echo "::warning::${FAILED} tag(s) failed to patch. Check the log above for details." | |
| fi |