Files
firebase-ios-sdk/.github/workflows/update-cpp-sdk-on-release.yml
T
Nick Cooke 9a6e89c829 [Infra] Add GHA behavior where old workflows are cancelled when new commit is pushed to a PR (#9498)
* Add top-level concurrency context to all workflows

* [will revert] Kill all workflows from previous commit

* [skip ci] Revert "[will revert] Kill all workflows from previous commit"

This reverts commit c6cf40ac9a.

* [skip ci] Don't cancel in progress for `generate_issues.yml`

* Experiment with conditonal cancellation

* [keep ci] this would be cool if it worked

* Try again

* [keep ci] try again

* Undo experiment and try to cancel `health-metrics-*`

* [skip ci] Revert `health-metrics-presubmit.yml`
2022-03-22 13:00:02 -04:00

68 lines
3.1 KiB
YAML

# Whenever a new Firebase iOS SDK is released, this workflow triggers *another*
# workflow on the Firebase C++ SDK, which will check for the iOS version update
# and create a PR updating its iOS dependencies if the version number has
# changed.
name: update-cpp-sdk-on-release
on:
release:
types: [ published ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
trigger_cpp_sdk_update:
# Only when a new release (not just the CocoaPods-* tag) is published.
if: ${{ (github.event_name == 'release' && !contains(github.ref, 'CocoaPods')) }}
# Fetch an authentication token for firebase-workflow-trigger, then use that
# token to trigger the update-dependencies workflow in firebase-cpp-sdk.
name: Trigger C++ SDK update
runs-on: ubuntu-latest
steps:
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Check out firebase-cpp-sdk
uses: actions/checkout@v2.3.1
with:
repository: firebase/firebase-cpp-sdk
ref: main
- name: Get firebase-workflow-trigger token
uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.CPP_WORKFLOW_TRIGGER_APP_ID }}
private_key: ${{ secrets.CPP_WORKFLOW_TRIGGER_APP_PRIVATE_KEY }}
repository: firebase/firebase-cpp-sdk
- name: Ensure Cocoapods repo has been updated
run: |
# If the new version is simply vX.Y.Z, wait up to an hour for its podspec to be present.
if [[ "$GITHUB_REF" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Checking Cocoapods repo for associated Firebase ${GITHUB_REF:1} podspec."
podspec_url="https://github.com/CocoaPods/Specs/blob/master/Specs/0/3/5/Firebase/${GITHUB_REF:1}/Firebase.podspec.json"
for retry in {1..12} error; do
# Check every 5 minutes, up to an hour, for the new podspec to be present.
# If it's still not present, trigger the update anyway.
if [[ $retry == "error" ]]; then
echo "::warning ::Firebase ${GITHUB_REF:1} podspec not found, updating anyway."
exit 0
fi
echo -n "Check ${podspec_url} (attempt ${retry}) ..."
curl -L -f -o /dev/null "${podspec_url}" 2> /dev/null && echo " success!" && break
echo " failed."
sleep 300
done
else
echo "Tag '$GITHUB_REF' doesn't match the 'vX.Y.Z' format, skipping Cocoapods repo check."
fi
- name: Trigger firebase-cpp-sdk update
run: |
pip install -r scripts/gha/requirements.txt
python scripts/gha/trigger_workflow.py -t ${{ steps.generate-token.outputs.token }} -w update-dependencies.yml -p updateAndroid 0 -p updateiOS 1 -p comment "[Triggered]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) by [firebase-ios-sdk $GITHUB_REF release]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$GITHUB_REF)." -s 10 -A