From cce2e3b1b09ca0d766a1d5f575c0e231570e5503 Mon Sep 17 00:00:00 2001 From: Xiaotian Wu Date: Fri, 26 Aug 2022 10:39:41 +0800 Subject: [PATCH] preview PR in different urls --- .github/workflows/preview-clean.yml | 32 +++++++++++++++++++++++++++++ .github/workflows/preview.yml | 14 +++++++------ 2 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/preview-clean.yml diff --git a/.github/workflows/preview-clean.yml b/.github/workflows/preview-clean.yml new file mode 100644 index 0000000..df26575 --- /dev/null +++ b/.github/workflows/preview-clean.yml @@ -0,0 +1,32 @@ +name: website-preview-clean + +on: + pull_request_target: + types: [closed] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Check out preview pages + uses: actions/checkout@v3 + with: + repository: loongarch64/website-preview + fetch-depth: 1 + submodules: true + ref: 'gh-pages' + + - name: Remove closed PR pages + run: rm -rvf ${{ github.event.pull_request.number }} + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} + external_repository: loongarch64/website-preview + allow_empty_commit: true + publish_branch: gh-pages + publish_dir: . + cname: preview.loongarch.dev + #force_orphan: true diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index f810f8f..c093333 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Check out main - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 1 submodules: true @@ -18,8 +18,10 @@ jobs: - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: - hugo-version: '0.79.1' - # extended: true + hugo-version: 'latest' + + - name: update baseURL for preview website + run: echo "baseURL = \"https://preview.loongarch.dev/${{ github.event.pull_request.number }}\"" > config/preview/config.toml - name: Build run: hugo --minify --environment preview --cleanDestinationDir @@ -32,7 +34,8 @@ jobs: allow_empty_commit: true publish_dir: ./public cname: preview.loongarch.dev - #force_orphan: true + destination_dir: ${{ github.event.pull_request.number }} + force_orphan: false - name: Update status uses: Sibz/github-status-action@v1 @@ -41,6 +44,5 @@ jobs: context: 'website-preview / deploy (update)' description: 'Deployed, click "Details" to view ->' state: 'success' - target_url: https://preview.loongarch.dev + target_url: https://preview.loongarch.dev/${{ github.event.pull_request.number }} sha: ${{github.event.pull_request.head.sha || github.sha}} -