Use repository permissions and branch pushes for CI [skip ci]

This commit is contained in:
Andras Schmelczer 2026-11-11 21:38:34 +00:00
commit bc1b79e770
2 changed files with 14 additions and 38 deletions

View file

@ -2,14 +2,10 @@ name: Check
on: on:
push: push:
branches: ['main']
pull_request:
branches: ['main']
jobs: jobs:
check: check:
runs-on: ${{ (github.actor == 'renovate-bot' || github.event.pull_request.user.login == 'renovate-bot' || startsWith(github.ref, 'refs/heads/renovate/') || startsWith(github.head_ref, runs-on: docker
'renovate/')) && 'renovate' || 'docker' }}
steps: steps:
- uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262 - uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
@ -46,5 +42,3 @@ jobs:
- name: Build - name: Build
run: npm run build run: npm run build
if: ${{ contains(fromJSON('["andras","ruby336688","renovate-bot"]'), github.actor) && (!github.event.pull_request || contains(fromJSON('["andras","ruby336688","renovate-bot"]'),
github.event.pull_request.user.login)) }}

View file

@ -2,25 +2,24 @@ name: Publish
on: on:
push: push:
branches: ['main'] branches:
tags: ['*'] - '**'
tags:
- '*'
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build: build:
runs-on: ${{ (github.actor == 'renovate-bot' || github.event.pull_request.user.login == 'renovate-bot' || startsWith(github.ref, 'refs/heads/renovate/') || startsWith(github.head_ref, runs-on: docker
'renovate/')) && 'renovate' || 'docker' }}
steps: steps:
- uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262 - uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with: with:
persist-credentials: false persist-credentials: false
- name: Setup Node - name: Setup Node
uses: https://github.com/actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 uses: https://github.com/actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with: with:
node-version: '22.x' node-version: 22.x
check-latest: true check-latest: true
- name: Cache npm dependencies - name: Cache npm dependencies
uses: https://github.com/actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 uses: https://github.com/actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
with: with:
@ -28,51 +27,39 @@ jobs:
key: ${{ runner.os }}-npm-${{ hashFiles('package.json') }} key: ${{ runner.os }}-npm-${{ hashFiles('package.json') }}
restore-keys: | restore-keys: |
${{ runner.os }}-npm- ${{ runner.os }}-npm-
- name: Install dependencies - name: Install dependencies
run: npm install run: npm install
- name: Check formatting - name: Check formatting
run: npm run format run: npm run format
- name: Lint - name: Lint
run: npm run lint run: npm run lint
- name: Type-check - name: Type-check
run: npm test run: npm test
- name: Build library and docs - name: Build library and docs
run: npm run build run: npm run build
- name: Upload static site artifact 1 - name: Upload static site artifact 1
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') }} if: ${{ github.ref == 'refs/heads/main' }}
uses: https://github.com/actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 uses: https://github.com/actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5
with: with:
name: pages-build-0 name: pages-build-0
path: docs path: docs
if-no-files-found: error if-no-files-found: error
retention-days: 1 retention-days: 1
if: ${{ contains(fromJSON('["andras","ruby336688","renovate-bot"]'), github.actor) && (!github.event.pull_request || contains(fromJSON('["andras","ruby336688","renovate-bot"]'),
github.event.pull_request.user.login)) }}
publish-npm: publish-npm:
needs: build needs: build
runs-on: ${{ (github.actor == 'renovate-bot' || github.event.pull_request.user.login == 'renovate-bot' || startsWith(github.ref, 'refs/heads/renovate/') || startsWith(github.head_ref, runs-on: docker
'renovate/')) && 'renovate' || 'docker' }} if: ${{ startsWith(github.ref, 'refs/tags/') }}
if: ${{ contains(fromJSON('["andras","ruby336688","renovate-bot"]'), github.actor) && (!github.event.pull_request || contains(fromJSON('["andras","ruby336688","renovate-bot"]'),
github.event.pull_request.user.login)) && (startsWith(github.ref, 'refs/tags/')) }}
steps: steps:
- uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262 - uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with: with:
persist-credentials: false persist-credentials: false
- name: Setup Node - name: Setup Node
uses: https://github.com/actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 uses: https://github.com/actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with: with:
node-version: '22.x' node-version: 22.x
check-latest: true check-latest: true
registry-url: 'https://registry.npmjs.org' registry-url: https://registry.npmjs.org
- name: Cache npm dependencies - name: Cache npm dependencies
uses: https://github.com/actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 uses: https://github.com/actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
with: with:
@ -80,17 +67,12 @@ jobs:
key: ${{ runner.os }}-npm-${{ hashFiles('package.json') }} key: ${{ runner.os }}-npm-${{ hashFiles('package.json') }}
restore-keys: | restore-keys: |
${{ runner.os }}-npm- ${{ runner.os }}-npm-
- name: Install dependencies - name: Install dependencies
run: npm install run: npm install
- name: Build library - name: Build library
run: npm run build run: npm run build
- name: Publish to NPM - name: Publish to NPM
run: npm publish run: npm publish
env: env:
NODE_AUTH_TOKEN: ${{ !(github.actor == 'renovate-bot' || github.event.pull_request.user.login == 'renovate-bot' || startsWith(github.ref, 'refs/heads/renovate/') NODE_AUTH_TOKEN: ${{ (secrets.NPM_TOKEN || '') }}
|| startsWith(github.head_ref, 'renovate/')) && (secrets.NPM_TOKEN) || '' }} if: ${{ (github.ref == 'refs/heads/main' || github.ref_type == 'tag') }}
if: ${{ !(github.actor == 'renovate-bot' || github.event.pull_request.user.login == 'renovate-bot' || startsWith(github.ref, 'refs/heads/renovate/') || startsWith(github.head_ref,
'renovate/')) }}