ci: GitHub workflow files for testing and deployment

This commit is contained in:
Hendrik Eeckhaut
2025-05-15 16:19:57 +02:00
parent 08392d228d
commit 0eaf834f69
2 changed files with 32 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
name: Deploy TLSnotary landing page to GitHub Pages name: Deploy to GitHub Pages
on: on:
# Runs on pushes targeting the default branch # Runs on pushes targeting the default branch
@@ -8,12 +8,6 @@ on:
# Allows you to run this workflow manually from the Actions tab # Allows you to run this workflow manually from the Actions tab
workflow_dispatch: workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency: concurrency:
@@ -21,12 +15,14 @@ concurrency:
cancel-in-progress: false cancel-in-progress: false
jobs: jobs:
# Build job
build: build:
name: Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect package manager - name: Detect package manager
id: detect-package-manager id: detect-package-manager
run: | run: |
@@ -51,30 +47,14 @@ jobs:
cache: ${{ steps.detect-package-manager.outputs.manager }} cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Setup Pages - name: Setup Pages
uses: actions/configure-pages@v5 uses: actions/configure-pages@v5
with:
# Automatically inject basePath in your Next.js configuration file and disable
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
#
# You may remove this line if you want to manage the configuration yourself.
static_site_generator: next
- name: Restore cache
uses: actions/cache@v4
with:
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Install dependencies - name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Build with Next.js - name: Build
run: ${{ steps.detect-package-manager.outputs.runner }} next build run: ${{ steps.detect-package-manager.outputs.runner }} run build
- name: Upload artifact - name: Upload artifact
uses: actions/upload-pages-artifact@v3 uses: actions/upload-pages-artifact@v3
with: with:
path: ./out path: build
# Deployment job # Deployment job
deploy: deploy:
@@ -83,6 +63,10 @@ jobs:
url: ${{ steps.deployment.outputs.page_url }} url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
steps: steps:
- name: Deploy to GitHub Pages - name: Deploy to GitHub Pages
id: deployment id: deployment

21
.github/workflows/test-deploy.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Test deployment
on:
pull_request:
jobs:
test-deploy:
name: Test deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Test build website
run: npm run build