From 66f44d3c392bde590562169f42674fc17a1ac3fc Mon Sep 17 00:00:00 2001 From: Marco Vockner Date: Wed, 7 Aug 2024 17:44:33 +0200 Subject: [PATCH] fix: deployment via github actions This will replace the bash script with npm run commands and also add the missing deploy-pages script to the github workflow. --- .github/workflows/deploy.yml | 47 +++++++++++++++++++++++++++++++----- build.sh | 12 --------- package.json | 4 ++- 3 files changed, 44 insertions(+), 19 deletions(-) delete mode 100755 build.sh diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 156e751..a4e5b48 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,12 +1,32 @@ -name: Deploy Pages +name: Deploy to GitHub Pages on: + # Runs on pushes targeting the default branch push: - branches: - - master + branches: [$default-branch] + + # 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: + group: "pages" + cancel-in-progress: false + +# Default to bash +defaults: + run: + shell: bash jobs: - deploy: + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -18,6 +38,10 @@ jobs: with: node-version: 20.x + - name: Setup Pages + id: pages + uses: actions/configure-pages@v5 + - name: Cache node_modules uses: actions/cache@v4 with: @@ -26,7 +50,7 @@ jobs: - name: Install dependencies run: | - npm install + npm ci shell: bash - name: Build @@ -34,7 +58,18 @@ jobs: npm run build shell: bash - - name: Upload Pages artifact + - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: ./public + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100755 index 1aaecba..0000000 --- a/build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -o errexit -set -o pipefail -set -o nounset - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -pushd "$SCRIPT_DIR" - -hexo clean -hexo generate -(cd ./public && postcss css/style.css --replace) diff --git a/package.json b/package.json index c478f8e..60f0768 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "scripts": { "start": "hexo server --log", "generate": "hexo generate", - "build": "./build.sh", + "build": "npm run clean && npm run build:hexo && npm run build:css", + "build:hexo": "hexo generate", + "build:css": "postcss ./public/css/style.css --replace --verbose", "clean": "hexo clean" }, "dependencies": {