From 833872e55b758ea57d0212f66738b5009ba90973 Mon Sep 17 00:00:00 2001 From: djamaile Date: Fri, 9 Dec 2022 11:19:02 +0100 Subject: [PATCH 1/4] chore: use changeset feedback action Signed-off-by: djamaile --- .../workflows/automate_changeset_feedback.yml | 73 +------------------ 1 file changed, 4 insertions(+), 69 deletions(-) diff --git a/.github/workflows/automate_changeset_feedback.yml b/.github/workflows/automate_changeset_feedback.yml index 700eae7d0c..b6b5ea3d7e 100644 --- a/.github/workflows/automate_changeset_feedback.yml +++ b/.github/workflows/automate_changeset_feedback.yml @@ -21,75 +21,10 @@ jobs: if: github.repository == 'backstage/backstage' && github.event.pull_request.user.login != 'backstage-service' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: backstage/actions/changeset-feedback@v0.5.9 with: # Fetch the commit that's merged into the base rather than the target ref # This will let us diff only the contents of the PR, without fetching more history - ref: 'refs/pull/${{ github.event.pull_request.number }}/merge' - - - name: fetch base - run: git fetch --depth 1 origin ${{ github.base_ref }} - - # We avoid using the in-source script since this workflow has elevated permissions that we don't want to expose - - name: Generate Feedback - id: generate-feedback - run: | - rm -f generate.js - wget -O generate.js https://raw.githubusercontent.com/backstage/backstage/master/scripts/generate-changeset-feedback.js 1>&2 - node generate.js FETCH_HEAD > feedback.txt - - - name: Post Feedback - uses: actions/github-script@v6 - env: - ISSUE_NUMBER: ${{ github.event.pull_request.number }} - with: - script: | - const owner = "backstage"; - const repo = "backstage"; - const marker = ""; - const feedback = require('fs').readFileSync('feedback.txt', 'utf8'); - const issue_number = Number(process.env.ISSUE_NUMBER); - const body = feedback.trim() ? feedback + marker : undefined - - const existingComments = await github.paginate(github.rest.issues.listComments, { - owner, - repo, - issue_number, - }); - - const existingComment = existingComments.find((c) => - c.user.login === "github-actions[bot]" && - c.body.includes(marker) - ); - - if (existingComment) { - if (body) { - if (existingComment.body !== body) { - console.log(`updating existing comment in #${issue_number}`); - await github.rest.issues.updateComment({ - owner, - repo, - comment_id: existingComment.id, - body, - }); - } else { - console.log(`skipped update of identical comment in #${issue_number}`); - } - } else { - console.log(`removing comment from #${issue_number}`); - await github.rest.issues.deleteComment({ - owner, - repo, - comment_id: existingComment.id, - body, - }); - } - } else if (body) { - console.log(`creating comment for #${issue_number}`); - await github.rest.issues.createComment({ - owner, - repo, - issue_number, - body, - }); - } + diffRef: 'refs/pull/${{ github.event.pull_request.number }}/merge' + github-token: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }} + issue-number: ${{ steps.pr-number.outputs.pr-number }} From a162f33a5f9ca17071b9418b14ed3e36dbfadbcb Mon Sep 17 00:00:00 2001 From: Djam Date: Fri, 9 Dec 2022 15:32:02 +0100 Subject: [PATCH 2/4] Update automate_changeset_feedback.yml Signed-off-by: Djam --- .github/workflows/automate_changeset_feedback.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/automate_changeset_feedback.yml b/.github/workflows/automate_changeset_feedback.yml index b6b5ea3d7e..3637ed11e7 100644 --- a/.github/workflows/automate_changeset_feedback.yml +++ b/.github/workflows/automate_changeset_feedback.yml @@ -21,10 +21,13 @@ jobs: if: github.repository == 'backstage/backstage' && github.event.pull_request.user.login != 'backstage-service' runs-on: ubuntu-latest steps: - - uses: backstage/actions/changeset-feedback@v0.5.9 + - uses: backstage/actions/changeset-feedback@vchangeset-patches with: # Fetch the commit that's merged into the base rather than the target ref # This will let us diff only the contents of the PR, without fetching more history diffRef: 'refs/pull/${{ github.event.pull_request.number }}/merge' github-token: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }} issue-number: ${{ steps.pr-number.outputs.pr-number }} + app-id: ${{ secrets.BACKSTAGE_GOALIE_APPLICATION_ID }} + private-key: ${{ secrets.BACKSTAGE_GOALIE_PRIVATE_KEY }} + installation-id: ${{ secrets.BACKSTAGE_GOALIE_INSTALLATION_ID }} From 9cfb9842c89fc95095c6f6ab547c303f401dd30e Mon Sep 17 00:00:00 2001 From: Djam Date: Mon, 12 Dec 2022 13:47:58 +0100 Subject: [PATCH 3/4] Update automate_changeset_feedback.yml Signed-off-by: Djam --- .github/workflows/automate_changeset_feedback.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/automate_changeset_feedback.yml b/.github/workflows/automate_changeset_feedback.yml index 3637ed11e7..dc1b22fc8c 100644 --- a/.github/workflows/automate_changeset_feedback.yml +++ b/.github/workflows/automate_changeset_feedback.yml @@ -26,7 +26,6 @@ jobs: # Fetch the commit that's merged into the base rather than the target ref # This will let us diff only the contents of the PR, without fetching more history diffRef: 'refs/pull/${{ github.event.pull_request.number }}/merge' - github-token: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }} issue-number: ${{ steps.pr-number.outputs.pr-number }} app-id: ${{ secrets.BACKSTAGE_GOALIE_APPLICATION_ID }} private-key: ${{ secrets.BACKSTAGE_GOALIE_PRIVATE_KEY }} From 177245cdadb10352167d851623dc7ea56bb8bf82 Mon Sep 17 00:00:00 2001 From: Djam Date: Mon, 19 Dec 2022 21:09:13 +0100 Subject: [PATCH 4/4] Update automate_changeset_feedback.yml Signed-off-by: Djam --- .github/workflows/automate_changeset_feedback.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/automate_changeset_feedback.yml b/.github/workflows/automate_changeset_feedback.yml index dc1b22fc8c..d27f0b84e0 100644 --- a/.github/workflows/automate_changeset_feedback.yml +++ b/.github/workflows/automate_changeset_feedback.yml @@ -21,12 +21,20 @@ jobs: if: github.repository == 'backstage/backstage' && github.event.pull_request.user.login != 'backstage-service' runs-on: ubuntu-latest steps: - - uses: backstage/actions/changeset-feedback@vchangeset-patches + - uses: actions/checkout@v3 with: # Fetch the commit that's merged into the base rather than the target ref # This will let us diff only the contents of the PR, without fetching more history - diffRef: 'refs/pull/${{ github.event.pull_request.number }}/merge' - issue-number: ${{ steps.pr-number.outputs.pr-number }} + ref: 'refs/pull/${{ github.event.pull_request.number }}/merge' + - name: fetch base + run: git fetch --depth 1 origin ${{ github.base_ref }} + - uses: backstage/actions/changeset-feedback@v0.5.12 + name: Generate feedback + with: + diffRef: 'origin/master' + marker: + issue-number: ${{ github.event.pull_request.number }} + botUsername: github-actions[bot] app-id: ${{ secrets.BACKSTAGE_GOALIE_APPLICATION_ID }} private-key: ${{ secrets.BACKSTAGE_GOALIE_PRIVATE_KEY }} installation-id: ${{ secrets.BACKSTAGE_GOALIE_INSTALLATION_ID }}