From 0eaf834f698fafca63cb55d79586d0abec85ff33 Mon Sep 17 00:00:00 2001 From: Hendrik Eeckhaut Date: Thu, 15 May 2025 16:19:57 +0200 Subject: [PATCH] ci: GitHub workflow files for testing and deployment --- .github/workflows/build_deploy_master.yml | 38 +++++++---------------- .github/workflows/test-deploy.yml | 21 +++++++++++++ 2 files changed, 32 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/test-deploy.yml diff --git a/.github/workflows/build_deploy_master.yml b/.github/workflows/build_deploy_master.yml index 9790912..47e9226 100644 --- a/.github/workflows/build_deploy_master.yml +++ b/.github/workflows/build_deploy_master.yml @@ -1,4 +1,4 @@ -name: Deploy TLSnotary landing page to GitHub Pages +name: Deploy to GitHub Pages on: # Runs on pushes targeting the default branch @@ -8,12 +8,6 @@ on: # Allows you to run this workflow manually from the Actions tab 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. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: @@ -21,12 +15,14 @@ concurrency: cancel-in-progress: false jobs: - # Build job build: + name: Build runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Detect package manager id: detect-package-manager run: | @@ -51,30 +47,14 @@ jobs: cache: ${{ steps.detect-package-manager.outputs.manager }} - name: Setup Pages 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 run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} - - name: Build with Next.js - run: ${{ steps.detect-package-manager.outputs.runner }} next build + - name: Build + run: ${{ steps.detect-package-manager.outputs.runner }} run build - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: ./out + path: build # Deployment job deploy: @@ -83,6 +63,10 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest 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: - name: Deploy to GitHub Pages id: deployment diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml new file mode 100644 index 0000000..642b34f --- /dev/null +++ b/.github/workflows/test-deploy.yml @@ -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