From dc70f82b6d5ed99e038aeba3c5ad890b4a696798 Mon Sep 17 00:00:00 2001 From: Cameron Koegel Date: Mon, 5 Dec 2022 13:40:23 -0500 Subject: [PATCH 1/2] DX-2933 Update PR Comment Action --- .github/actions/add_pr_comment/action.yml | 31 ----------------------- .github/workflows/listener.yml | 17 ++++++++----- 2 files changed, 10 insertions(+), 38 deletions(-) delete mode 100644 .github/actions/add_pr_comment/action.yml diff --git a/.github/actions/add_pr_comment/action.yml b/.github/actions/add_pr_comment/action.yml deleted file mode 100644 index 34631c44e..000000000 --- a/.github/actions/add_pr_comment/action.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Add PR Comment -description: Adds a PR comment on an open PR in another repository -inputs: - username: - required: true - description: Github Username - token: - required: true - description: Github Password - repo-name: - required: true - description: The name of the repository the comment is being made in - pr-number: - required: true - description: Pull Request or Issue Number from api-specs repo - message: - required: true - description: The message to be used as the PR comment - -runs: - using: "composite" - steps: - - name: Make PR Comment - run: | - curl \ - -X POST \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/Bandwidth/${{ inputs.repo-name }}/issues/${{ inputs.pr-number }}/comments \ - -u ${{ inputs.username }}:${{ inputs.token }} \ - -d '{"body": "${{ inputs.message }}"}' - shell: bash diff --git a/.github/workflows/listener.yml b/.github/workflows/listener.yml index 7943c53af..12fc4471e 100644 --- a/.github/workflows/listener.yml +++ b/.github/workflows/listener.yml @@ -42,14 +42,17 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }} + # Comment on PR - name: Comment on Corresponding Repo - uses: ./.github/actions/add_pr_comment - with: - username: ${{ secrets.DX_GITHUB_USERNAME }} - token: ${{ secrets.DX_GITHUB_TOKEN }} - repo-name: ${{ github.event.client_payload.originRepo }} - pr-number: ${{ github.event.client_payload.prNumber }} - message: 'Preview site: http://bw-api-docs-${{ env.BRANCH_NAME }}.s3-website-us-east-1.amazonaws.com/\nPlease note that it may take a couple minutes for your preview site to become available.\n\nSee the corresponding PR opened on the docsite repository (no action required):\nhttps://github.com/Bandwidth/api-docs/pull/${{ env.PR_NUMBER }}' + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.createComment({ + issue_number: ${{ github.event.client_payload.prNumber }}, + owner: 'Bandwidth', + repo: ${{ github.event.client_payload.originRepo }}, + body: 'Preview site: http://bw-api-docs-${{ env.BRANCH_NAME }}.s3-website-us-east-1.amazonaws.com/\nPlease note that it may take a couple minutes for your preview site to become available.\n\nSee the corresponding PR opened on the docsite repository (no action required):\nhttps://github.com/Bandwidth/api-docs/pull/${{ env.PR_NUMBER }}' + }) merge: if: ${{ github.event.action == 'Merge' }} From b39471708fa3ca2bc0adbd9d697db02e0ffcacdc Mon Sep 17 00:00:00 2001 From: Cameron Koegel Date: Mon, 5 Dec 2022 13:44:21 -0500 Subject: [PATCH 2/2] fix other instances --- .github/workflows/listener.yml | 38 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/.github/workflows/listener.yml b/.github/workflows/listener.yml index 12fc4471e..d7c2de85f 100644 --- a/.github/workflows/listener.yml +++ b/.github/workflows/listener.yml @@ -66,13 +66,17 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }} - - uses: ./.github/actions/add_pr_comment - with: - username: ${{ secrets.DX_GITHUB_USERNAME }} - token: ${{ secrets.DX_GITHUB_TOKEN }} - repo-name: api-docs - pr-number: ${{ env.PR_NUMBER }} - message: 'Corresponding Pull Request on [${{ github.event.client_payload.originRepo }}](https://github.com/Bandwidth/${{ github.event.client_payload.originRepo }}/pull/${{ github.event.client_payload.prNumber }}) was merged.' + # Comment on PR + - name: Comment on Corresponding Repo + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.createComment({ + issue_number: ${{ env.PR_NUMBER }}, + owner: 'Bandwidth', + repo: 'api-docs', + body: 'Corresponding Pull Request on [${{ github.event.client_payload.originRepo }}](https://github.com/Bandwidth/${{ github.event.client_payload.originRepo }}/pull/${{ github.event.client_payload.prNumber }}) was merged.' + }) close: if: ${{ github.event.action == 'Close' }} @@ -91,14 +95,18 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }} - - uses: ./.github/actions/add_pr_comment - with: - username: ${{ secrets.DX_GITHUB_USERNAME }} - token: ${{ secrets.DX_GITHUB_TOKEN }} - repo-name: api-docs - pr-number: ${{ env.PR_NUMBER }} - message: 'Corresponding Pull Request on [${{ github.event.client_payload.originRepo }}](https://github.com/Bandwidth/${{ github.event.client_payload.originRepo }}/pull/${{ github.event.client_payload.prNumber }}) was closed.' - + # Comment on PR + - name: Comment on Corresponding Repo + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.createComment({ + issue_number: ${{ env.PR_NUMBER }}, + owner: 'Bandwidth', + repo: 'api-docs', + body: 'Corresponding Pull Request on [${{ github.event.client_payload.originRepo }}](https://github.com/Bandwidth/${{ github.event.client_payload.originRepo }}/pull/${{ github.event.client_payload.prNumber }}) was closed.' + }) + change_draft_status: if: ${{ github.event.action == 'Draft' }} runs-on: ubuntu-latest