From b95139668837f0fed4b38ed0056175c14eb299d0 Mon Sep 17 00:00:00 2001 From: rodrigozhou Date: Thu, 30 May 2024 17:47:42 -0500 Subject: [PATCH] Replace GHA token in workflow to trigger api-go update --- .github/workflows/trigger-api-go-update.yml | 32 +++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/.github/workflows/trigger-api-go-update.yml b/.github/workflows/trigger-api-go-update.yml index 1b8d6cbb9..cd4382891 100644 --- a/.github/workflows/trigger-api-go-update.yml +++ b/.github/workflows/trigger-api-go-update.yml @@ -16,14 +16,30 @@ jobs: shell: bash steps: + - name: Generate token + if: ${{ !env.ACT }} + id: generate_token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }} + private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }} + - name: Dispatch api-go Github Action env: - PAT: ${{ secrets.COMMANDER_DATA_TOKEN }} - PARENT_REPO: temporalio/api-go - PARENT_BRANCH: ${{ toJSON('master') }} - WORKFLOW_ID: update-proto.yml - COMMIT_AUTHOR: ${{ toJSON(github.event.head_commit.author.name) }} - COMMIT_AUTHOR_EMAIL: ${{ toJSON(github.event.head_commit.author.email) }} - COMMIT_MESSAGE: ${{ toJSON(github.event.head_commit.message) }} + GH_TOKEN: ${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }} + COMMIT_AUTHOR: rodrigozhou + COMMIT_AUTHOR_EMAIL: rodrigo.zhou@temporal.io + COMMIT_MESSAGE: test run: | - curl -fL -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ env.PAT }}" https://api.github.com/repos/${{ env.PARENT_REPO }}/actions/workflows/${{ env.WORKFLOW_ID }}/dispatches -d '{"ref":'"$PARENT_BRANCH"', "inputs":{"commit_author":'"$COMMIT_AUTHOR"', "commit_author_email":'"$COMMIT_AUTHOR_EMAIL"', "commit_message":'"$COMMIT_MESSAGE"'}}' \ No newline at end of file + # curl -X POST \ + # -H "Accept: application/vnd.github.v3+json" \ + # -H "Authorization: token $GH_TOKEN" \ + # https://api.github.com/repos/temporalio/api-go/actions/workflows/update-proto.yml/dispatches \ + # -d '{"ref":"master", "inputs":{"branch":"rodrigozhou/test", "commit_author":'"$COMMIT_AUTHOR"', "commit_author_email":'"$COMMIT_AUTHOR_EMAIL"', "commit_message":'"$COMMIT_MESSAGE"'}}' + + gh workflow run update-proto.yml -R https://github.com/temporalio/api-go \ + -r master \ + -f branch="rodrigozhou/test" \ + -f commit_author="${COMMIT_AUTHOR}" \ + -f commit_author_email="${COMMIT_AUTHOR_EMAIL}" \ + -f commit_message="${COMMIT_MESSAGE}"