Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions .github/workflows/preview-cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: cleanup-preview

on:
pull_request:
types: [closed]

jobs:
cleanup-preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages

- name: Remove preview directory
run: |
if [ -d "pr-${{ github.event.pull_request.number }}" ]; then
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git rm -rf pr-${{ github.event.pull_request.number }}
git commit -m "Remove preview for PR #${{ github.event.pull_request.number }}"
git push
else
echo "Preview directory not found, skipping cleanup"
fi
61 changes: 61 additions & 0 deletions .github/workflows/preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: deploy-preview

on:
pull_request:
types: [opened, synchronize, reopened]

concurrency:
group: preview-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: "0.115.1"
extended: true

- name: Build
run: hugo --baseURL https://blog.kyu08.com/pr-${{ github.event.pull_request.number }}/

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
destination_dir: pr-${{ github.event.pull_request.number }}
keep_files: true
cname: blog.kyu08.com

- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: プレビュー環境

- name: Create or update 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: |
## プレビュー環境

プレビュー環境が更新されました。

**URL:** https://blog.kyu08.com/pr-${{ github.event.pull_request.number }}/

**Commit:** [`${{ github.event.pull_request.head.sha }}`](${{ github.event.repository.html_url }}/commit/${{ github.event.pull_request.head.sha }})

※ デプロイ完了まで数分かかる場合があります。
edit-mode: replace