From 3dd81ff71873e48fc75cc13f0dec4b716cf20a79 Mon Sep 17 00:00:00 2001 From: Joe Anderson Date: Thu, 21 Dec 2023 18:01:17 +0000 Subject: [PATCH] Add /release:next magic comment --- .github/workflows/comment.yml | 69 +++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/comment.yml diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml new file mode 100644 index 0000000..d750737 --- /dev/null +++ b/.github/workflows/comment.yml @@ -0,0 +1,69 @@ +# Define actions that run in response to comments on issues and PRs +# Based on https://github.com/ianstormtaylor/slate/blob/main/.github/workflows/comment.yml +# +# Allowed GitHub users: zbeyens, 12joan +# +# Supported comments: +# - /release:next (PR only) - Publish the branch to NPM with tag 'next' + +name: Comment + +on: + issue_comment: + types: + - created + +jobs: + release_next: + permissions: + contents: read # to fetch code (actions/checkout) + pull-requests: write # to create or update comment (peter-evans/create-or-update-comment) + + name: release:next + runs-on: ubuntu-latest + if: | + github.event.issue.pull_request && + contains(['zbeyens', '12joan'], github.event.sender.login) && + startsWith(github.event.comment.body, '/release:next') + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Checkout pull request + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: 20.x + cache: yarn + registry-url: https://registry.npmjs.org + key: node20 + + - name: ♻️ Use Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: 📥 Monorepo install + uses: ./.github/actions/yarn-nm-install + + - name: Publish to NPM + run: yarn release:next + env: + # See https://github.com/changesets/action/issues/147 + HOME: ${{ github.workspace }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Create comment + uses: peter-evans/create-or-update-comment@v1 + with: + issue-number: ${{ github.event.issue.number }} + body: | + A new release has been made for this pull request. diff --git a/package.json b/package.json index 76d710a..5754635 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "typecheck": "yarn g:typecheck", "typedoc": "npx typedoc --options scripts/typedoc.json", "release": "yarn build && yarn changeset publish", + "release:next": "yarn build && yarn changeset publish --tag next", "g:brl": "turbo --filter \"./packages/**\" brl --no-daemon", "g:build": "turbo --filter \"./packages/**\" build --no-daemon", "g:build:watch": "yarn build:watch", @@ -25,7 +26,6 @@ "g:clean": "yarn clean:turbo && turbo --filter \"./packages/**\" clean --no-daemon", "g:lint": "turbo --filter \"./packages/**\" lint --no-daemon", "g:lint:fix": "turbo lint:fix --no-daemon", - "g:release:next": "yarn yarn build && yarn changeset publish --tag next", "g:test": "turbo --filter \"./packages/**\" test --no-daemon", "g:test:watch": "turbo --filter \"./packages/**\" test:watch --no-daemon", "g:test:cov": "yarn g:test --coverage",