Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed github page CI #534

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
on:
push:
tags:
- "v*.*.*"
pull_request:

env:
Expand All @@ -12,8 +9,15 @@ name: Deploying on GitHub Pages
jobs:
deploy_preview:
name: Deploy preview versions on pull requests
if: startsWith(github.ref, "refs/pull/")
runs-on: ubuntu-latest
permissions:
deployments: write
pull-requests: write
contents: write

environment:
name: PR-${{ github.event.pull_request.number }}
url: ${{ steps.configure.outputs.URL }}

steps:
- name: Checkout repository
Expand Down Expand Up @@ -44,10 +48,34 @@ jobs:
- name: Build Web version
run: ./scripts/build-web.sh

- name: Configure environments
id: configure
env:
FOLDER: ${{ github.event.pull_request.number }}
run: |
echo "URL=https://$GITHUB_REPOSITORY_OWNER.github.io/${GITHUB_REPOSITORY##*/}/$FOLDER" >> $GITHUB_OUTPUT

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/web
cname: "tk"
publish_dir: build/web
keep_files: true
destination_dir: "${{ github.event.pull_request.number }}"

- name: Find deployment comment
uses: peter-evans/find-comment@v2
id: fc
with:
comment-author: "github-actions[bot]"
issue-number: ${{ github.event.pull_request.number }}
body-includes: "This PR has been deployed to"

- name: Create or update deployment comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
This PR has been deployed to ${{ step.configure.outputs.URL }}
edit-mode: replace