Skip to content

Clean CI

Clean CI #89

Workflow file for this run

name: ANTLR Editor CI
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
test_lint:
runs-on: ubuntu-latest
if: ${{ !github.event.created && github.repository != 'garronej/ts-ci' }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v4
with:
node-version: 22
- name: If this step fails run 'yarn lint' and 'yarn format' then commit again.
run: |
yarn
yarn lint:check
yarn format:check
test:
runs-on: ${{ matrix.os }}
needs: test_lint
strategy:
matrix:
node: ["22"]
os: [windows-latest, ubuntu-latest]
name: Test with Node v${{ matrix.node }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- uses: bahmutov/npm-install@v1
- run: |
yarn
yarn test:coverage
yarn build
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage/coverage-final.json
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
build_storybook:
name: Build Storybook app
needs: test
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.ref }}
- name: Upload sample files
uses: actions/upload-artifact@v4
with:
name: samples
path: samples/
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Build Storybook
run: |
yarn
yarn build-storybook
- name: Upload Storybook artifact
uses: actions/upload-artifact@v4
with:
name: storybook-static
path: storybook-static/
deploy_storybook:
name: Deploy Storybook on Github Pages
needs: build_storybook
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download samples artifact
uses: actions/download-artifact@v4
with:
name: samples
path: samples
- name: Download Storybook artifact
uses: actions/download-artifact@v4
with:
name: storybook-static
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .
check_if_version_upgraded:
name: Check if version upgrade
# When someone forks the repo and opens a PR we want to enables the tests to be run (the previous jobs)
# but obviously only us should be allowed to release.
# In the following check we make sure that we own the branch this CI workflow is running on before continuing.
# Without this check, trying to release would fail anyway because only us have the correct secret.NPM_TOKEN but
# it's cleaner to stop the execution instead of letting the CI crash.
if: |
github.event_name == 'push' ||
github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
runs-on: ubuntu-latest
needs: test
outputs:
from_version: ${{ steps.step1.outputs.from_version }}
to_version: ${{ steps.step1.outputs.to_version }}
is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }}
is_pre_release: ${{steps.step1.outputs.is_pre_release }}
steps:
- uses: garronej/ts-ci@v2.1.0
id: step1
with:
action_name: is_package_json_version_upgraded
branch: ${{ github.head_ref || github.ref }}
publish_on_npm:
runs-on: ubuntu-latest
needs: check_if_version_upgraded
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.ref }}
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: "https://registry.npmjs.org"
- name: Update NPM
run: npm install -g npm@latest
- name: Install dependencies with NPM
run: npm install
- name: Build with NPM
run: npm run build
- name: Publish with NPM
run: npm publish