Skip to content

ci: set NODE_AUTH_TOKEN for releases #350

ci: set NODE_AUTH_TOKEN for releases

ci: set NODE_AUTH_TOKEN for releases #350

Workflow file for this run

name: Changesets
on:
pull_request:
types:
- opened
- labeled
- edited
- synchronize
jobs:
changeset_check:
name: Changeset added to the PR
# Adding 'skip changesets' label to the PR will skip this job
if: ${{ !contains( github.event.pull_request.labels.*.name, 'skip changeset') && !startsWith(github.head_ref, 'changeset-release/') }}
runs-on: ubuntu-22.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
sparse-checkout: ./.changeset
- name: Changeset file lookup
env:
GH_TOKEN: ${{ github.token }}
PR_ID: ${{ github.event.number }}
run: |
files=$(gh pr diff "$PR_ID" --name-only)
if [[ $files =~ \.changeset\/.*.md ]]; then
echo "Changesets found!"
else
echo "There is no changeset file in your pull request."
exit 1
fi
skip_changeset_validation:
name: Validate skip changeset usage
if: ${{ contains(github.event.pull_request.labels.*.name, 'skip changeset') }}
runs-on: ubuntu-22.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Ensure no release-impacting files changed
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
run: |
set -euo pipefail
git fetch origin "$BASE_REF" --depth=1
changed_files=$(git diff --name-only FETCH_HEAD)
printf '%s\n' "Files changed in PR:" "$changed_files"
if [ -z "$changed_files" ]; then
echo "No file changes detected."
exit 0
fi
if printf '%s\n' "$changed_files" | grep -Eq '^(src/|dist/|bin/|schema\.json$|SCHEMA\.md$)'; then
echo "The 'skip changeset' label cannot be used when application source or schema files change."
exit 1
fi
if printf '%s\n' "$changed_files" | grep -Eq '^pnpm-lock\.yaml$'; then
echo "The 'skip changeset' label cannot be used when lockfiles change."
exit 1
fi
if printf '%s\n' "$changed_files" | grep -Eq '^package\.json$'; then
pkg_diff=$(git diff FETCH_HEAD -- package.json)
if printf '%s\n' "$pkg_diff" | grep -Eq '^[+-].*\"(version|dependencies|devDependencies|peerDependencies|optionalDependencies)\"'; then
echo "The 'skip changeset' label cannot be used when package.json version or dependencies change."
exit 1
fi
fi
echo "Skip changeset validation passed."