From 2e8b8f5de03939c30b806853a9460d665a977c54 Mon Sep 17 00:00:00 2001 From: Norbert Elter <72046715+itsyoboieltr@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:00:50 +0200 Subject: [PATCH 1/6] feat: add-team-label reusable workflow --- ...-team-label-to-pr.ts => add-team-label.ts} | 6 ++-- .github/workflows/add-team-label.yml | 33 +++---------------- package.json | 4 +-- 3 files changed, 9 insertions(+), 34 deletions(-) rename .github/scripts/{add-team-label-to-pr.ts => add-team-label.ts} (93%) diff --git a/.github/scripts/add-team-label-to-pr.ts b/.github/scripts/add-team-label.ts similarity index 93% rename from .github/scripts/add-team-label-to-pr.ts rename to .github/scripts/add-team-label.ts index fbbbe30cac3..40461c598bd 100644 --- a/.github/scripts/add-team-label-to-pr.ts +++ b/.github/scripts/add-team-label.ts @@ -16,11 +16,11 @@ async function main(): Promise { // We can't use "GITHUB_TOKEN" here, as its permissions are scoped to the repository where the action is running. // "GITHUB_TOKEN" does not have access to other repositories, even when they belong to the same organization. // As we want to get files which are not necessarily located in the same repository, - // we need to create our own "RELEASE_LABEL_TOKEN" with "repo" permissions. + // we need to create our own "PERSONAL_ACCESS_TOKEN" with "repo" permissions. // Such a token allows to access other repositories of the MetaMask organisation. - const personalAccessToken = process.env.RELEASE_LABEL_TOKEN; + const personalAccessToken = process.env.PERSONAL_ACCESS_TOKEN; if (!personalAccessToken) { - core.setFailed('RELEASE_LABEL_TOKEN not found'); + core.setFailed('PERSONAL_ACCESS_TOKEN not found'); process.exit(1); } diff --git a/.github/workflows/add-team-label.yml b/.github/workflows/add-team-label.yml index eba9e48c1f1..02a75aefd4a 100644 --- a/.github/workflows/add-team-label.yml +++ b/.github/workflows/add-team-label.yml @@ -1,4 +1,4 @@ -name: Add team label to PR when it is opened +name: Add team label on: pull_request: @@ -7,31 +7,6 @@ on: jobs: add-team-label: - runs-on: ubuntu-latest - steps: - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 'lts/*' - - - run: corepack enable - - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 # This is needed to checkout all branches - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: yarn - - - name: Install dependencies - run: yarn --immutable - - - name: Add team label to PR - id: add-team-label-to-pr - env: - RELEASE_LABEL_TOKEN: ${{ secrets.RELEASE_LABEL_TOKEN }} - run: yarn run add-team-label-to-pr + uses: metamask/github-tools/.github/workflows/add-team-label.yml@main + secrets: + PERSONAL_ACCESS_TOKEN: ${{ secrets.RELEASE_LABEL_TOKEN }} diff --git a/package.json b/package.json index ebba355f2b4..6f1b86697ec 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "deduplicate": "yarn yarn-deduplicate && yarn install", "set-version": "./scripts/set-versions.sh", "add-release-label-to-pr-and-linked-issues": "ts-node ./.github/scripts/add-release-label-to-pr-and-linked-issues.ts", - "add-team-label-to-pr": "ts-node ./.github/scripts/add-team-label-to-pr.ts", + "add-team-label": "ts-node ./.github/scripts/add-team-label.ts", "run-bitrise-e2e-check": "ts-node ./.github/scripts/bitrise/run-bitrise-e2e-check.ts", "fitness-functions": "ts-node ./.github/scripts/fitness-functions/index.ts", "check-pr-has-required-labels": "ts-node ./.github/scripts/check-pr-has-required-labels.ts", @@ -583,4 +583,4 @@ } }, "packageManager": "yarn@1.22.22" -} \ No newline at end of file +} From 413799611a035308f5b2ecb724812f9dfa598989 Mon Sep 17 00:00:00 2001 From: Norbert Elter <72046715+itsyoboieltr@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:44:42 +0200 Subject: [PATCH 2/6] Update add-team-label.yml --- .github/workflows/add-team-label.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/add-team-label.yml b/.github/workflows/add-team-label.yml index 02a75aefd4a..dce7e8a5889 100644 --- a/.github/workflows/add-team-label.yml +++ b/.github/workflows/add-team-label.yml @@ -4,6 +4,7 @@ on: pull_request: types: - opened + - reopened jobs: add-team-label: From 9c5120ea84203b7fb863a488a7c9234b1420c5a7 Mon Sep 17 00:00:00 2001 From: Norbert Elter <72046715+itsyoboieltr@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:47:52 +0200 Subject: [PATCH 3/6] Update add-team-label.yml --- .github/workflows/add-team-label.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/add-team-label.yml b/.github/workflows/add-team-label.yml index dce7e8a5889..02a75aefd4a 100644 --- a/.github/workflows/add-team-label.yml +++ b/.github/workflows/add-team-label.yml @@ -4,7 +4,6 @@ on: pull_request: types: - opened - - reopened jobs: add-team-label: From 1716ca25e696b8b7e6a26c62d56bf870d54083a9 Mon Sep 17 00:00:00 2001 From: Norbert Elter <72046715+itsyoboieltr@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:35:46 +0200 Subject: [PATCH 4/6] fix: workflow to commit hash --- .github/workflows/add-team-label.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add-team-label.yml b/.github/workflows/add-team-label.yml index 02a75aefd4a..e5b81985855 100644 --- a/.github/workflows/add-team-label.yml +++ b/.github/workflows/add-team-label.yml @@ -7,6 +7,6 @@ on: jobs: add-team-label: - uses: metamask/github-tools/.github/workflows/add-team-label.yml@main + uses: metamask/github-tools/.github/workflows/add-team-label.yml@7c10eb3bafb3f221111a9e4309ae5dcaee171de5 secrets: PERSONAL_ACCESS_TOKEN: ${{ secrets.RELEASE_LABEL_TOKEN }} From 72e46976285afe29c824b7cd021e7b0b7d488e04 Mon Sep 17 00:00:00 2001 From: Norbert Elter <72046715+itsyoboieltr@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:36:47 +0200 Subject: [PATCH 5/6] Update add-team-label.yml --- .github/workflows/add-team-label.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/add-team-label.yml b/.github/workflows/add-team-label.yml index e5b81985855..d938f9cdffe 100644 --- a/.github/workflows/add-team-label.yml +++ b/.github/workflows/add-team-label.yml @@ -4,6 +4,7 @@ on: pull_request: types: - opened + - synchronize jobs: add-team-label: From c9d87b305293808ea9f35d96801e8615ce3b4876 Mon Sep 17 00:00:00 2001 From: Norbert Elter <72046715+itsyoboieltr@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:57:17 +0200 Subject: [PATCH 6/6] Update add-team-label.yml --- .github/workflows/add-team-label.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/add-team-label.yml b/.github/workflows/add-team-label.yml index d938f9cdffe..e5b81985855 100644 --- a/.github/workflows/add-team-label.yml +++ b/.github/workflows/add-team-label.yml @@ -4,7 +4,6 @@ on: pull_request: types: - opened - - synchronize jobs: add-team-label: