From e64e082f1d04e6b4a94cb914b1589f31a3c2e4da Mon Sep 17 00:00:00 2001 From: Christian Stussak Date: Mon, 3 Jun 2024 11:42:27 +0200 Subject: [PATCH] Add GitHub action for deploying to GitHub pages --- .github/workflows/deploy-pages.yml | 92 ++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/deploy-pages.yml diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml new file mode 100644 index 0000000..e81724c --- /dev/null +++ b/.github/workflows/deploy-pages.yml @@ -0,0 +1,92 @@ +name: Deploy to GitHub Pages + +on: + # Run on tag pushes matching starting with 'v' + push: + tags: + - 'v*' + + # ... Also run manually + workflow_dispatch: + +# 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: + group: "pages" + cancel-in-progress: false + +# Default to bash +defaults: + run: + shell: bash + +jobs: + # Build job + build: + runs-on: ubuntu-22.04 + timeout-minutes: 10 + permissions: + contents: write + pull-requests: read + env: + INPUT_PATH: "." + steps: + - name: Checkout + uses: actions/checkout@v4.1.6 + + - name: Set up Node.js + uses: actions/setup-node@v4.0.2 + with: + node-version: '20.9.x' + + - name: Install dependencies + run: npm clean-install + + - name: Build + run: npm run build + + - name: Fix permissions + run: | + chmod -c -R +rX "$INPUT_PATH" | while read line; do + echo "::warning title=Invalid file permissions automatically fixed::$line" + done + + - name: Archive artifact + shell: sh + run: | + echo ::group::Archive artifact + tar \ + --dereference --hard-dereference \ + --directory "$INPUT_PATH" \ + -cvf "$RUNNER_TEMP/artifact.tar" \ + --exclude=.git \ + --exclude=.github \ + --exclude=*/node_modules/* \ + --exclude=node_modules/* \ + $(test -f ../.releaseignore && echo "--exclude-from=../.releaseignore") \ + . + echo ::endgroup:: + + - name: Upload artifact + id: upload-artifact + uses: actions/upload-artifact@v4.3.3 + with: + name: github-pages + path: ${{ runner.temp }}/artifact.tar + retention-days: 1 + if-no-files-found: error + + deploy: + needs: build + runs-on: ubuntu-22.04 + timeout-minutes: 10 + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4.0.5