Skip to content

Auto-patch upstream runner tags #5

Auto-patch upstream runner tags

Auto-patch upstream runner tags #5

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 "[email protected]"
# 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}"
# Clean slate and checkout the upstream tag
git reset --hard
git clean -fd
git checkout "upstream/${TAG}" --detach 2>&1
# Cherry-pick the Bitrise cache integration commit
if git cherry-pick "${PATCH_COMMIT}"; 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} — skipping"
git cherry-pick --abort 2>/dev/null || git reset --hard
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