From 2ec803929d8acd74621164e71d3e30fc7353df72 Mon Sep 17 00:00:00 2001 From: Gabriel Gerez Date: Mon, 10 Jun 2024 13:38:19 +0200 Subject: [PATCH] Try something else --- .github/workflows/build-PR.yml | 66 ---------------------------------- .github/workflows/preview.yml | 40 +++++++++++++++++++++ 2 files changed, 40 insertions(+), 66 deletions(-) delete mode 100644 .github/workflows/build-PR.yml create mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/build-PR.yml b/.github/workflows/build-PR.yml deleted file mode 100644 index d083c67..0000000 --- a/.github/workflows/build-PR.yml +++ /dev/null @@ -1,66 +0,0 @@ -# Zola build workflow. - -# Prerequisites: -# - zola writes output to public/ -# - variables below set correctly -# -# Setting it up: -# It is a general limitation of gh-actions that they cannot make the very first -# deploy to gh-pages. It will seem to work, but not appear on the CDN to be -# online. You need to go to settings and set the gh-pages branch, then future -# deploys will work. See -# https://github.com/marketplace/actions/github-pages-action#%EF%B8%8F-first-deployment-with-github_token - -name: Build PR/deploy website - -env: - ZOLA_VERSION: "0.17.2" - MAIN_BRANCH: "main" - TARGET_BRANCH: "gh-pages" - CNAME: "hpc.uit.no" - -on: - pull_request: - branches: - - main - -permissions: - contents: write - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout repository and submodules - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Install zola - run: | - set -x - wget -O - \ - "https://github.com/getzola/zola/releases/download/v${ZOLA_VERSION}/zola-v${ZOLA_VERSION}-x86_64-unknown-linux-gnu.tar.gz" \ - | sudo tar xzf - -C /usr/local/bin - - name: Generate HTML - run: zola build - # Add CNAME, either (first one used) - # - file in the root - # - the environment variable set above - - name: add CNAME - run: | - if [ -f CNAME ] ; then - mv CNAME public/ - echo "Copied CNAME from repository root" - exit 0 - fi - if [ -n ${{ env.CNAME }} ] ; then - echo -n ${{ env.CNAME }} > public/CNAME - echo "Used CNAME from the action workflow file" - fi - - name: Deploy to gh-pages - if: ${{ github.event_name == 'pull_request'}} - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./public - force_orphan: true diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000..21ec884 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,40 @@ +# .github/workflows/preview.yml +name: Deploy PR previews + +env: + ZOLA_VERSION: "0.17.2" + # MAIN_BRANCH: "main" + # TARGET_BRANCH: "gh-pages" + # CNAME: "hpc.uit.no" +on: + pull_request: + types: + - opened + - reopened + - synchronize + - closed + +concurrency: preview-${{ github.ref }} + +jobs: + deploy-preview: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install zola + run: | + set -x + wget -O - \ + "https://github.com/getzola/zola/releases/download/v${ZOLA_VERSION}/zola-v${ZOLA_VERSION}-x86_64-unknown-linux-gnu.tar.gz" \ + | sudo tar xzf - -C /usr/local/bin + - name: Generate HTML + run: zola build + # Add CNAME, either (first one used) + # - file in the root + # - the environment variable set above + - name: Deploy preview + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./public \ No newline at end of file