Skip to content

Commit

Permalink
preview PR in different urls
Browse files Browse the repository at this point in the history
  • Loading branch information
yetist committed Aug 26, 2022
1 parent 63f3b19 commit cce2e3b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/preview-clean.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 8 additions & 6 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ jobs:

steps:
- name: Check out main
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: true

- 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
Expand All @@ -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
Expand All @@ -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}}

0 comments on commit cce2e3b

Please sign in to comment.