fix(is-production): crucial fix to detect main
correctly as production
#272
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# secrets.GITHUB_TOKEN is provided to each job by default, lifetime: 60minutes. | |
# See https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token | |
name: Lint, Test, Build and optionally Publish | |
on: | |
# push only for branches (ignore tags) | |
push: | |
branches: | |
- 'main' | |
tags-ignore: | |
- '**' | |
# pull request only for branches (ignore tags) | |
pull_request: | |
branches: | |
- '**' | |
tags-ignore: | |
- '**' | |
jobs: | |
checkExecution: | |
runs-on: ubuntu-latest | |
outputs: | |
shouldExecute: ${{ steps.stepCheckExecution.outputs.shouldExecute }} | |
steps: | |
- name: Dump GitHub context | |
run: | | |
echo "::group::github context" | |
echo "$GITHUB_CONTEXT" | |
echo "::endgroup::" | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
- id: stepCheckExecution | |
name: Check for execution | |
uses: shiftcode/[email protected] | |
with: | |
skipOnCommitMsg: "[skip_build]" | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
test: | |
runs-on: ubuntu-latest | |
needs: checkExecution | |
# only execute if not skipped by commit message | |
if: needs.checkExecution.outputs.shouldExecute == 'true' | |
strategy: | |
matrix: | |
# Test with Node.js v20 and v22 | |
node: | |
- 20 | |
- 22 | |
name: Node.js v${{ matrix.node }} | |
steps: | |
# checkout branch | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
# 0 indicates all history, because publish requires tag information | |
fetch-depth: 0 | |
# we need privileged access to publish to protected branch | |
token: ${{ secrets.GH_TOKEN_PUBLIC_REPO }} | |
# setup node and dependency cache | |
- name: Setup Node and NPM Cache | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node }} | |
cache: 'npm' | |
# install dependencies | |
- name: Install | |
run: HUSKY=0 npm ci | |
# test | |
- name: Test | |
run: npm run test:ci | |
build: | |
runs-on: ubuntu-latest | |
needs: [checkExecution, test] | |
# only execute if not skipped by commit message | |
if: needs.checkExecution.outputs.shouldExecute == 'true' | |
steps: | |
# checkout branch | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
# 0 indicates all history, because publish requires tag information | |
fetch-depth: 0 | |
# we need privileged access to publish to protected branch | |
token: ${{ secrets.GH_TOKEN_PUBLIC_REPO }} | |
# setup node and dependency cache | |
- name: Setup Node and NPM Cache | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: 'npm' | |
# install dependencies | |
- name: Install | |
run: HUSKY=0 npm ci | |
# build lint plugins before linting | |
- name: Build lint plugins | |
run: npm run build:lint:ci | |
# check formatting | |
- name: Check Formatting | |
run: npm run format:ci | |
# lint | |
- name: Lint | |
run: npm run lint:ci | |
# build | |
- name: Build | |
run: npm run build:ci | |
# publish | |
- name: Publish | |
run: | | |
npm config set //npm.pkg.github.com/:_authToken=$REGISTRY_TOKEN | |
git config user.email "[email protected]" | |
git config user.name "Github Actions" | |
npm run publish-libs | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_TOKEN: ${{ secrets.GH_TOKEN_PUBLIC_REPO }} # necessary for publish-libs script |