From e6b64c8f107533eee43299f7c2b902d97e58b1cd Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 3 Jan 2024 13:34:28 +0800 Subject: [PATCH 1/2] Use GITHUB_TOKEN in slash command workflows --- .github/workflows/ci_tests_dev.yaml | 15 +++------------ .github/workflows/format-command.yml | 11 ++--------- .github/workflows/slash-command-dispatch.yml | 9 +-------- 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci_tests_dev.yaml b/.github/workflows/ci_tests_dev.yaml index 4ba451d495f..348d9331c34 100644 --- a/.github/workflows/ci_tests_dev.yaml +++ b/.github/workflows/ci_tests_dev.yaml @@ -57,21 +57,12 @@ jobs: # fetch all history so that setuptools-scm works fetch-depth: 0 - # Generate token from GenericMappingTools bot - - name: Generate token from GenericMappingTools bot - uses: tibdex/github-app-token@v2 - if: github.event_name == 'repository_dispatch' - id: generate-token - with: - app_id: ${{ secrets.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} - # Checkout the pull request branch - name: Checkout uses: actions/checkout@v4.1.1 if: github.event_name == 'repository_dispatch' with: - token: ${{ steps.generate-token.outputs.token }} + token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} ref: ${{ github.event.client_payload.pull_request.head.ref }} # fetch all history so that setuptools-scm works @@ -79,9 +70,9 @@ jobs: - name: Show job URL uses: peter-evans/create-or-update-comment@v3.1.0 - if: github.event_name == 'repository_dispatch' && (matrix.os == 'ubuntu-latest') + if: github.event_name == 'repository_dispatch' && runner.os == 'Linux' with: - token: ${{ steps.generate-token.outputs.token }} + token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.event.client_payload.github.payload.repository.full_name }} comment-id: ${{ github.event.client_payload.github.payload.comment.id }} body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} diff --git a/.github/workflows/format-command.yml b/.github/workflows/format-command.yml index 51f00f8fb1f..2bdbb18c37e 100644 --- a/.github/workflows/format-command.yml +++ b/.github/workflows/format-command.yml @@ -10,17 +10,10 @@ jobs: format: runs-on: ubuntu-latest steps: - # Generate token from GenericMappingTools bot - - uses: tibdex/github-app-token@v2 - id: generate-token - with: - app_id: ${{ secrets.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} - # Checkout the pull request branch - uses: actions/checkout@v4.1.1 with: - token: ${{ steps.generate-token.outputs.token }} + token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} ref: ${{ github.event.client_payload.pull_request.head.ref }} @@ -52,7 +45,7 @@ jobs: - name: Add reaction uses: peter-evans/create-or-update-comment@v3.1.0 with: - token: ${{ steps.generate-token.outputs.token }} + token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.event.client_payload.github.payload.repository.full_name }} comment-id: ${{ github.event.client_payload.github.payload.comment.id }} reactions: hooray diff --git a/.github/workflows/slash-command-dispatch.yml b/.github/workflows/slash-command-dispatch.yml index 9762c56138d..ac7e4df9933 100644 --- a/.github/workflows/slash-command-dispatch.yml +++ b/.github/workflows/slash-command-dispatch.yml @@ -13,17 +13,10 @@ jobs: if: ${{ github.event.issue.pull_request }} runs-on: ubuntu-latest steps: - # Generate token from GenericMappingTools bot - - uses: tibdex/github-app-token@v2 - id: generate-token - with: - app_id: ${{ secrets.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} - - name: Slash Command Dispatch uses: peter-evans/slash-command-dispatch@v3 with: - token: ${{ steps.generate-token.outputs.token }} + token: ${{ secrets.GITHUB_TOKEN }} commands: | format test-gmt-dev From cef5cb9c8df99ef467953cd735309fe0b470be6e Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 4 Jan 2024 09:44:02 +0800 Subject: [PATCH 2/2] Revert the changes in format-command.yml --- .github/workflows/format-command.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/format-command.yml b/.github/workflows/format-command.yml index 5e31c483627..0cdad84b468 100644 --- a/.github/workflows/format-command.yml +++ b/.github/workflows/format-command.yml @@ -10,10 +10,17 @@ jobs: format: runs-on: ubuntu-latest steps: + # Generate token from GenericMappingTools bot + - uses: tibdex/github-app-token@v2 + id: generate-token + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + # Checkout the pull request branch - uses: actions/checkout@v4.1.1 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ steps.generate-token.outputs.token }} repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} ref: ${{ github.event.client_payload.pull_request.head.ref }} @@ -45,7 +52,7 @@ jobs: - name: Add reaction uses: peter-evans/create-or-update-comment@v3.1.0 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ steps.generate-token.outputs.token }} repository: ${{ github.event.client_payload.github.payload.repository.full_name }} comment-id: ${{ github.event.client_payload.github.payload.comment.id }} reactions: hooray