From f83b9580d08b9e6171259986fd7b706905ff80d5 Mon Sep 17 00:00:00 2001 From: "kirill.chalov" Date: Sat, 6 Jul 2024 23:30:11 +0800 Subject: [PATCH] feat: add workflow to preview prs --- .github/workflows/preview-pr.yml | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/preview-pr.yml diff --git a/.github/workflows/preview-pr.yml b/.github/workflows/preview-pr.yml new file mode 100644 index 000000000..8ffead108 --- /dev/null +++ b/.github/workflows/preview-pr.yml @@ -0,0 +1,50 @@ +name: Preview Hugo Site + +on: + pull_request: + branches: + - main + +# Set permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +# Default to bash +defaults: + run: + shell: bash + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Install Hugo CLI + env: + HUGO_VERSION: 0.120.4 + run: | + wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ + && sudo dpkg -i ${{ runner.temp }}/hugo.deb + + - name: Check out repo + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build the site + run: hugo --minify + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./public + # Deploy to a subdirectory for each PR + destination_dir: "preview/${{ github.event.number }}-${{ github.sha }}"