update-cpp-sdk-on-release.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Whenever a new Firebase iOS SDK is released, this workflow triggers *another*
  2. # workflow on the Firebase C++ SDK, which will check for the iOS version update
  3. # and create a PR updating its iOS dependencies if the version number has
  4. # changed.
  5. name: update-cpp-sdk-on-release
  6. on:
  7. release:
  8. types: [ published ]
  9. jobs:
  10. trigger_cpp_sdk_update:
  11. # Only when a new release (not just the CocoaPods-* tag) is published.
  12. if: ${{ (github.event_name == 'release' && !contains(github.ref, 'CocoaPods')) }}
  13. # Fetch an authentication token for firebase-workflow-trigger, then use that
  14. # token to trigger the update-dependencies workflow in firebase-cpp-sdk.
  15. name: Trigger C++ SDK update
  16. runs-on: ubuntu-latest
  17. steps:
  18. - name: Setup python
  19. uses: actions/setup-python@v2
  20. with:
  21. python-version: 3.7
  22. - name: Check out firebase-cpp-sdk
  23. uses: actions/checkout@v2.3.1
  24. with:
  25. repository: firebase/firebase-cpp-sdk
  26. ref: main
  27. - name: Get firebase-workflow-trigger token
  28. uses: tibdex/github-app-token@v1
  29. id: generate-token
  30. with:
  31. app_id: ${{ secrets.CPP_WORKFLOW_TRIGGER_APP_ID }}
  32. private_key: ${{ secrets.CPP_WORKFLOW_TRIGGER_APP_PRIVATE_KEY }}
  33. repository: firebase/firebase-cpp-sdk
  34. - name: Ensure Cocoapods repo has been updated
  35. run: |
  36. # If the new version is simply vX.Y.Z, wait up to an hour for its podspec to be present.
  37. if [[ "$GITHUB_REF" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
  38. echo "Checking Cocoapods repo for associated Firebase ${GITHUB_REF:1} podspec."
  39. podspec_url="https://github.com/CocoaPods/Specs/blob/master/Specs/0/3/5/Firebase/${GITHUB_REF:1}/Firebase.podspec.json"
  40. for retry in {1..12} error; do
  41. # Check every 5 minutes, up to an hour, for the new podspec to be present.
  42. # If it's still not present, trigger the update anyway.
  43. if [[ $retry == "error" ]]; then
  44. echo "::warning ::Firebase ${GITHUB_REF:1} podspec not found, updating anyway."
  45. exit 0
  46. fi
  47. echo -n "Check ${podspec_url} (attempt ${retry}) ..."
  48. curl -L -f -o /dev/null "${podspec_url}" 2> /dev/null && echo " success!" && break
  49. echo " failed."
  50. sleep 300
  51. done
  52. else
  53. echo "Tag '$GITHUB_REF' doesn't match the 'vX.Y.Z' format, skipping Cocoapods repo check."
  54. fi
  55. - name: Trigger firebase-cpp-sdk update
  56. run: |
  57. pip install -r scripts/gha/requirements.txt
  58. 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