From f47fe648e822f6b409fbc9fa3e23beb16848891f Mon Sep 17 00:00:00 2001 From: Ben Siggery Date: Wed, 24 Apr 2024 16:36:58 +0100 Subject: [PATCH 1/3] attempt to fix env var v2 --- .github/workflows/changeset-snapshot/test-aperture.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/changeset-snapshot/test-aperture.js b/.github/workflows/changeset-snapshot/test-aperture.js index 6095364565..f8afec10e9 100644 --- a/.github/workflows/changeset-snapshot/test-aperture.js +++ b/.github/workflows/changeset-snapshot/test-aperture.js @@ -38,8 +38,7 @@ module.exports = async ({ github, context }, execa) => { repo: 'pie-aperture', event_type: 'pie-trigger', client_payload: { - 'pie-branch': process.env.PIE_BRANCH, - 'pie-pr-number': process.env.PIE_PR_NUMBER, + 'pie-branch': process.env.GITHUB_REF_NAME, 'snapshot-version': snapshotVersion, 'snapshot-packages': packageNames.join(' ') } From 937394ecad2ebc27af9ef2a1cbd7321806bcbaec Mon Sep 17 00:00:00 2001 From: Ben Siggery Date: Wed, 6 Nov 2024 13:46:57 +0000 Subject: [PATCH 2/3] fix(pie-monorepo): WCP-000 update labeler --- .github/workflows/gather-pr-info.yml | 21 +++++++++++++ .github/workflows/labeler.yml | 44 ++++++++++++---------------- 2 files changed, 39 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/gather-pr-info.yml diff --git a/.github/workflows/gather-pr-info.yml b/.github/workflows/gather-pr-info.yml new file mode 100644 index 0000000000..c7bc66cfb3 --- /dev/null +++ b/.github/workflows/gather-pr-info.yml @@ -0,0 +1,21 @@ +name: Gather PR Info +on: pull_request + +jobs: + gather-info: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + # Gather necessary information and save it as an artifact + - name: Gather Information + run: | + # Example: Gather branch name or other necessary info + echo "PR_BRANCH_NAME=${{ github.event.pull_request.head.ref }}" > pr-info.txt + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: pr-info + path: pr-info.txt \ No newline at end of file diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 258a33bceb..ae4d0d8f61 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -1,40 +1,32 @@ name: Pull Request Labeler -on: pull_request_target -# By default, pull_request_target runs when the activity type is opened, synchronize, or reopened -# https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#pull_request_target +on: + workflow_run: + workflows: ["Gather PR Info"] + types: + - completed jobs: - categorise: + process-info: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@v4 - # Since this action runs on "pull_request_target", the current context is the "main" branch - # We need to pull the branch PR before performing the comparison in the "Add Missing Labels" step - - name: Fetch branch PR - env: - PR_NUMBER: ${{ github.event.pull_request.number }} - PR_BRANCH_NAME: ${{ github.event.pull_request.head.ref }} - run: | - git fetch origin pull/"$PR_NUMBER"/head:"$PR_BRANCH_NAME" + - name: Download Artifact + uses: actions/download-artifact@v3 + with: + name: pr-info + # Process the information and perform actions that require secrets - name: Add Missing Labels - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + uses: actions/github-script@v7 env: GITHUB_TOKEN: ${{ secrets.CHANGESETS_TOKEN }} - PR_BRANCH_NAME: ${{ github.event.pull_request.head.ref }} with: github-token: ${{ secrets.CHANGESETS_TOKEN }} script: | - const { PR_BRANCH_NAME } = process.env - const script = require('./.github/workflows/add-missing-labels/add-missing-labels.js') - await script({ github, context, prBranchName: PR_BRANCH_NAME }); - - - name: Labeler - uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # v4.3.0 - with: - configuration-path: '.github/project-labeler.yml' - repo-token: '${{ secrets.GITHUB_TOKEN }}' - # Category labels will be removed if they no longer apply - sync-labels: true + const fs = require('fs'); + const prInfo = fs.readFileSync('pr-info.txt', 'utf8'); + const prBranchName = prInfo.match(/PR_BRANCH_NAME=(.*)/)[1]; + const script = require('./.github/workflows/add-missing-labels/add-missing-labels.js'); + await script({ github, context, prBranchName }); \ No newline at end of file From 54978475069be4725003c5e1dda208cc68d3e984 Mon Sep 17 00:00:00 2001 From: Ben Siggery Date: Wed, 6 Nov 2024 13:49:34 +0000 Subject: [PATCH 3/3] fix(pie-monorepo): WCP-000 update labeler --- .github/workflows/changeset-snapshot/test-aperture.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/changeset-snapshot/test-aperture.js b/.github/workflows/changeset-snapshot/test-aperture.js index f8afec10e9..6095364565 100644 --- a/.github/workflows/changeset-snapshot/test-aperture.js +++ b/.github/workflows/changeset-snapshot/test-aperture.js @@ -38,7 +38,8 @@ module.exports = async ({ github, context }, execa) => { repo: 'pie-aperture', event_type: 'pie-trigger', client_payload: { - 'pie-branch': process.env.GITHUB_REF_NAME, + 'pie-branch': process.env.PIE_BRANCH, + 'pie-pr-number': process.env.PIE_PR_NUMBER, 'snapshot-version': snapshotVersion, 'snapshot-packages': packageNames.join(' ') }