|
| 1 | +# Whenever a new Firebase Android SDK is released, this workflow triggers |
| 2 | +# *another* workflow on the Firebase C++ SDK, which will check for the Android |
| 3 | +# version update and create a PR updating its dependencies if any version |
| 4 | +# numbers changed. |
| 5 | +name: update-cpp-sdk-on-release |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + # Change the below line if the main branch is renamed. |
| 10 | + - 'master' |
| 11 | + paths: |
| 12 | + # Only run this if a gradle.properties file is touched. |
| 13 | + - '**/gradle.properties' |
| 14 | + |
| 15 | +jobs: |
| 16 | + check_if_version_changed: |
| 17 | + name: Check if released version changed |
| 18 | + # This step checks several things, and sets released_version_changed=1 only if all are true: |
| 19 | + # - The push must target the main branch. |
| 20 | + # - The push must modify a gradle.properties file. |
| 21 | + # - The push must change a "latestReleasedVersion=" line in a gradle.properties file. |
| 22 | + runs-on: ubuntu-latest |
| 23 | + outputs: |
| 24 | + released_version_changed: ${{ steps.check_version.outputs.released_version_changed }} |
| 25 | + steps: |
| 26 | + |
| 27 | + with: |
| 28 | + # Check out the actual head commit, not any merge commit. |
| 29 | + ref: ${{ github.sha }} |
| 30 | + # Specify fetch-depth so we can query the log, the default is a shallow clone. |
| 31 | + fetch-depth: 0 |
| 32 | + - name: Check if version was updated in git history |
| 33 | + id: check_version |
| 34 | + run: | |
| 35 | + # Query the git history for all gradle.properties files changed by this push. |
| 36 | + # Then, check the diff to see if any "latestReleasedVersion=" lines changed. |
| 37 | + if (git diff '${{ github.event.before }}' -- '**/gradle.properties' | grep -q '^[-+]latestReleasedVersion='); then |
| 38 | + echo "::set-output name=released_version_changed::1" |
| 39 | + else |
| 40 | + echo "No change to latestReleasedVersion detected since ${{ github.event.before }}" |
| 41 | + fi |
| 42 | +
|
| 43 | + trigger_cpp_sdk_update: |
| 44 | + name: Trigger C++ SDK update |
| 45 | + # If the previous step set the released_version_changed output param to 1, then |
| 46 | + # we should trigger the C++ SDK to update its Android dependencies. |
| 47 | + needs: check_if_version_changed |
| 48 | + if: ${{ needs.check_if_version_changed.outputs.released_version_changed }} |
| 49 | + # Fetch an authentication token for firebase-workflow-trigger, then use that |
| 50 | + # token to trigger the update-dependencies workflow in firebase-cpp-sdk. |
| 51 | + runs-on: ubuntu-latest |
| 52 | + steps: |
| 53 | + - name: Setup python |
| 54 | + uses: actions/setup-python@v2 |
| 55 | + with: |
| 56 | + python-version: 3.7 |
| 57 | + |
| 58 | + - name: Check out firebase-cpp-sdk |
| 59 | + |
| 60 | + with: |
| 61 | + repository: firebase/firebase-cpp-sdk |
| 62 | + ref: main |
| 63 | + |
| 64 | + - name: Get firebase-workflow-trigger token |
| 65 | + uses: tibdex/github-app-token@v1 |
| 66 | + id: generate-token |
| 67 | + with: |
| 68 | + app_id: ${{ secrets.CPP_WORKFLOW_TRIGGER_APP_ID }} |
| 69 | + private_key: ${{ secrets.CPP_WORKFLOW_TRIGGER_APP_PRIVATE_KEY }} |
| 70 | + repository: firebase/firebase-cpp-sdk |
| 71 | + |
| 72 | + - name: Trigger firebase-cpp-sdk update |
| 73 | + run: | |
| 74 | + python scripts/gha/trigger_workflow.py -t ${{ steps.generate-token.outputs.token }} -w update-dependencies.yml -p updateAndroid 1 -p updateiOS 0 -p comment "[Triggered]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) by [firebase-android-sdk $(date '+%b %d') release]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/${{ github.sha }})." -s 10 -A |
0 commit comments