Skip to content

Commit

Permalink
Replace GHA token in workflow to trigger api-go update
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigozhou committed May 30, 2024
1 parent 31201e4 commit b951396
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions .github/workflows/trigger-api-go-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]
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"'}}'
# 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}"

0 comments on commit b951396

Please sign in to comment.