From 410082aa8adf35f51383442c984bef44250d398a Mon Sep 17 00:00:00 2001 From: Skye <46286597+Skye-31@users.noreply.github.com> Date: Sun, 11 Sep 2022 17:15:41 +0100 Subject: [PATCH] Refactor version packages label adding --- .github/gh-label.cjs | 13 +++++++++++++ .github/workflows/release.yml | 5 +++++ .github/workflows/versionPackagesLabel.yml | 20 -------------------- 3 files changed, 18 insertions(+), 20 deletions(-) create mode 100644 .github/gh-label.cjs delete mode 100644 .github/workflows/versionPackagesLabel.yml diff --git a/.github/gh-label.cjs b/.github/gh-label.cjs new file mode 100644 index 0000000..ed62be2 --- /dev/null +++ b/.github/gh-label.cjs @@ -0,0 +1,13 @@ +const { execSync } = require("child_process"); + +const res = execSync("gh pr status --json title -q .currentBranch.title") + .toString() + .trim(); +const title = "Version Packages"; + +if (res === title) { + console.log("Adding label 'version-packages'"); + execSync('gh pr edit --add-label "Version Packages"'); +} else { + console.log("No version packages PR"); +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e30ea6b..458f1dc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,3 +43,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Add label + run: node ./.github/gh-label.cjs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/versionPackagesLabel.yml b/.github/workflows/versionPackagesLabel.yml deleted file mode 100644 index 606e4d9..0000000 --- a/.github/workflows/versionPackagesLabel.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Version packages label -on: - pull_request: - types: [opened, reopened] - -jobs: - label_pr_when_open: - name: Add the ready label when a pr is open - if: ${{ github.event.pull_request.title == 'Version Packages' }} - runs-on: ubuntu-latest - - steps: - - name: Label a pr when opened - id: approved - uses: lightspeedretail/actions-label-prs@v1 - with: - task: "label_pr_add" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ADD_LABEL: "Version Packages"