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 49a0c8369c

View file

@ -2,20 +2,14 @@ name: Check & deploy
on: on:
push: push:
branches: ['main']
pull_request:
branches: ['main']
workflow_dispatch: workflow_dispatch:
jobs: jobs:
validate: validate:
outputs: outputs:
publish: ${{ steps.validated_build.outcome }} publish: ${{ steps.validated_build.outcome }}
env: env:
PHOTO_ASSET_CACHE_URL: https://photos.schmelczer.dev/static/photos/ PHOTO_ASSET_CACHE_URL: https://photos.schmelczer.dev/static/photos/
runs-on: runs-on: docker
${{ (github.actor == 'renovate-bot' || github.event.pull_request.user.login == 'renovate-bot' || startsWith(github.ref, 'refs/heads/renovate/') || startsWith(github.head_ref,
'renovate/')) && 'renovate' || 'docker' }}
# Superseded validation runs can be cancelled freely. # Superseded validation runs can be cancelled freely.
concurrency: concurrency:
group: 'photos-validate-${{ github.ref }}' group: 'photos-validate-${{ github.ref }}'
@ -23,51 +17,37 @@ jobs:
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-file: '.nvmrc' node-version-file: .nvmrc
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
- name: Lint and static checks - name: Lint and static checks
run: npm run lint:check run: npm run lint:check
- name: Unit tests - name: Unit tests
run: npm test run: npm test
- name: Build - name: Build
run: npm run build run: npm run build
- name: Install Playwright browser - name: Install Playwright browser
run: npx playwright install --with-deps --only-shell chromium run: npx playwright install --with-deps --only-shell chromium
- name: End-to-end smoke test - name: End-to-end smoke test
env: env:
PLAYWRIGHT_USE_EXISTING_BUILD: '1' PLAYWRIGHT_USE_EXISTING_BUILD: '1'
run: npm run test:e2e run: npm run test:e2e
- name: Save validated build - name: Save validated build
id: validated_build id: validated_build
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && contains(fromJSON('["andras","ruby336688"]'), github.actor) }} 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-deploy-0 name: pages-deploy-0
path: dist path: dist
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)) }}
deploy: deploy:
runs-on: runs-on: docker
${{ (github.actor == 'renovate-bot' || github.event.pull_request.user.login == 'renovate-bot' || startsWith(github.ref, 'refs/heads/renovate/') || startsWith(github.head_ref,
'renovate/')) && 'renovate' || 'docker' }}
needs: validate needs: validate
# The upload step evaluates the trusted-main condition on the runner. Pass # The upload step evaluates the trusted-main condition on the runner. Pass
# its result to Forgejo's dependent-job scheduler instead of repeating it. # its result to Forgejo's dependent-job scheduler instead of repeating it.