diff --git a/.github/workflows/manual-prepare_release_branch.yml b/.github/workflows/manual-prepare_release_branch.yml index ee69f99..85f4845 100644 --- a/.github/workflows/manual-prepare_release_branch.yml +++ b/.github/workflows/manual-prepare_release_branch.yml @@ -180,9 +180,17 @@ jobs: runs-on: ubuntu-latest needs: bump_and_branch steps: + - name: Create App token + id: app-token + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + with: + client-id: ${{ vars.MOBILE_CI_APP_CLIENT_ID }} + private-key: ${{ secrets.MOBILE_CI_APP_PRIVATE_KEY }} + permission-contents: read + permission-pull-requests: write - name: Build PR body and open PR env: - GITHUB_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} + GH_TOKEN: ${{ steps.app-token.outputs.token }} SRC: ${{ needs.bump_and_branch.outputs.release_branch }} DST: ${{ github.event.inputs.target_branch }} REPO: ${{ github.repository }} diff --git a/.github/workflows/publish-common-trigger.yml b/.github/workflows/publish-common-trigger.yml index 64b732a..def21e0 100644 --- a/.github/workflows/publish-common-trigger.yml +++ b/.github/workflows/publish-common-trigger.yml @@ -35,7 +35,7 @@ jobs: with: branch: ${{ github.ref_name }} secrets: - PAT_FOR_TRIGGERING_BRANCH_PROTECTION: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} + MOBILE_CI_APP_PRIVATE_KEY: ${{ secrets.MOBILE_CI_APP_PRIVATE_KEY }} publish-from-pr: if: github.event_name == 'pull_request' && github.event.pull_request.merged == true @@ -46,4 +46,4 @@ jobs: with: branch: ${{ github.base_ref }} secrets: - PAT_FOR_TRIGGERING_BRANCH_PROTECTION: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} + MOBILE_CI_APP_PRIVATE_KEY: ${{ secrets.MOBILE_CI_APP_PRIVATE_KEY }} diff --git a/.github/workflows/publish-reusable.yml b/.github/workflows/publish-reusable.yml index 79ff146..9d95560 100644 --- a/.github/workflows/publish-reusable.yml +++ b/.github/workflows/publish-reusable.yml @@ -7,7 +7,7 @@ on: required: true type: string secrets: - PAT_FOR_TRIGGERING_BRANCH_PROTECTION: + MOBILE_CI_APP_PRIVATE_KEY: required: true permissions: @@ -106,19 +106,26 @@ jobs: startsWith(github.head_ref, 'release/') && github.base_ref == 'master' runs-on: ubuntu-latest - env: - # gh uses this PAT, not the workflow GITHUB_TOKEN — needed so the merge PR - # re-triggers branch-protection checks. Job-level `permissions:` only scope - # the workflow token, so they don't apply to these gh calls. - GITHUB_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} steps: + - name: Create App token + id: app-token + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + with: + client-id: ${{ vars.MOBILE_CI_APP_CLIENT_ID }} + private-key: ${{ secrets.MOBILE_CI_APP_PRIVATE_KEY }} + permission-contents: write + permission-pull-requests: write - name: Checkout develop branch uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: develop - name: Create Pull Request + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} run: gh pr create --base develop --head master --title "Merge 'master' into 'develop' after release" --body "Automated Pull Request to merge 'master' into 'develop' after release" - name: Merge Pull Request + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} run: | pr_number=$(gh pr list --base develop --head master --json number --jq '.[0].number') gh pr merge "$pr_number" --merge --auto