Skip to content

fix: changeset PR update not running workflows #4855

fix: changeset PR update not running workflows

fix: changeset PR update not running workflows #4855

Workflow file for this run

name: Release to @pr-<number> tag on npm
on:
pull_request:
workflow_dispatch:
jobs:
release-pr:
name: "Release PR to npm"
runs-on: ubuntu-latest
# comment out if:false to enable release PR to npm
if: false
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: CI Setup
uses: ./.github/actions/ci-setup
- name: Ensure NPM access
run: npm whoami
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build
run: pnpm build
- name: Release to @pr-${{ github.event.pull_request.number }} tag on npm
id: release
run: |
pnpm changeset:next
git add .changeset/fuel-labs-ci.md
pnpm changeset version --snapshot pr-${{ env.PR_NUMBER }}
changetsets=$(pnpm changeset publish --tag pr-${{ env.PR_NUMBER }})
published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-pr-${{ env.PR_NUMBER }}-\d+' | head -1)
echo "published_version=$published_version" >> $GITHUB_OUTPUT
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
- uses: mshick/add-pr-comment@v2
with:
message: |
This PR is published in NPM with version **${{ steps.release.outputs.published_version }}**
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}