Update CI

This commit is contained in:
garronej 2023-04-03 20:24:58 +02:00
parent 034f6f8b0e
commit 1073a610d6

View File

@ -17,44 +17,32 @@ jobs:
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
- uses: bahmutov/npm-install@v1 - uses: bahmutov/npm-install@v1
- name: If this step fails run 'yarn format' then commit again. - name: If this step fails run 'yarn format' then commit again.
run: | run: yarn format:check
PACKAGE_MANAGER=npm
if [ -f "./yarn.lock" ]; then
PACKAGE_MANAGER=yarn
fi
$PACKAGE_MANAGER run format:check
test: test:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
needs: test_lint needs: test_lint
strategy: strategy:
matrix: matrix:
node: [ '16' ] node: [ '17' ]
os: [ ubuntu-latest ] os: [ ubuntu-latest ]
name: Test with Node v${{ matrix.node }} on ${{ matrix.os }} name: Test with Node v${{ matrix.node }} on ${{ matrix.os }}
steps: steps:
- name: Tell if project is using npm or yarn
id: step1
uses: garronej/ts-ci@v2.0.2
with:
action_name: tell_if_project_uses_npm_or_yarn
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
- uses: bahmutov/npm-install@v1 - uses: bahmutov/npm-install@v1
- if: steps.step1.outputs.npm_or_yarn == 'yarn' - run: yarn build
run: | - run: yarn test
yarn build - run: yarn test:keycloakify-starter
yarn test
- if: steps.step1.outputs.npm_or_yarn == 'npm'
run: |
npm run build
npm test
check_if_version_upgraded: check_if_version_upgraded:
name: Check if version upgrade name: Check if version upgrade
# We run this only if it's a push on the default branch or if it's a PR from a # When someone forks the repo and opens a PR we want to enables the tests to be run (the previous jobs)
# branch (meaning not a PR from a fork). It would be more straightforward to test if secrets.NPM_TOKEN is # but obviously only us should be allowed to release.
# defined but GitHub Action don't allow it yet. # 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: | if: |
github.event_name == 'push' || github.event_name == 'push' ||
github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
@ -66,7 +54,7 @@ jobs:
is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }} is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }}
is_pre_release: ${{steps.step1.outputs.is_pre_release }} is_pre_release: ${{steps.step1.outputs.is_pre_release }}
steps: steps:
- uses: garronej/ts-ci@v2.0.2 - uses: garronej/ts-ci@v2.1.0
id: step1 id: step1
with: with:
action_name: is_package_json_version_upgraded action_name: is_package_json_version_upgraded
@ -74,8 +62,8 @@ jobs:
create_github_release: create_github_release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
# We create a release only if the version have been upgraded and we are on the main branch # We create release only if the version in the package.json have been upgraded and this CI is running against the main branch.
# or if we are on a branch of the repo that has an PR open on main. # We allow branches with a PR open on main to publish pre-release (x.y.z-rc.u) but not actual releases.
if: | if: |
needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' && needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' &&
( (
@ -109,15 +97,13 @@ jobs:
with: with:
registry-url: https://registry.npmjs.org/ registry-url: https://registry.npmjs.org/
- uses: bahmutov/npm-install@v1 - uses: bahmutov/npm-install@v1
- run: | - run: yarn build
PACKAGE_MANAGER=npm - run: npx -y -p denoify@1.3.0 enable_short_npm_import_path
if [ -f "./yarn.lock" ]; then
PACKAGE_MANAGER=yarn
fi
$PACKAGE_MANAGER run build
- run: npx -y -p denoify@1.2.2 enable_short_npm_import_path
env: env:
DRY_RUN: "0" DRY_RUN: "0"
- uses: garronej/ts-ci@v2.1.0
with:
action_name: remove_dark_mode_specific_images_from_readme
- name: Publishing on NPM - name: Publishing on NPM
run: | run: |
if [ "$(npm show . version)" = "$VERSION" ]; then if [ "$(npm show . version)" = "$VERSION" ]; then