Skip to content

Commit 34b73d5

Browse files
authored
Merge pull request #1 from urandom-ctf/add-github-actions
Add GitHub Actions
2 parents 4f22462 + 5ae4389 commit 34b73d5

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build and deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
10+
jobs:
11+
build-deploy:
12+
runs-on: self-hosted
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
submodules: recursive # to fetch Hugo themes
17+
18+
- uses: dorny/paths-filter@v3
19+
id: changes
20+
with:
21+
filters: |
22+
src:
23+
- 'static/**'
24+
- '**/*.md'
25+
- 'layouts/**'
26+
27+
- name: Setup Hugo
28+
uses: peaceiris/actions-hugo@v3
29+
with:
30+
hugo-version: '0.119.0'
31+
extended: true
32+
33+
- name: Build
34+
run: hugo --minify
35+
36+
- uses: webfactory/[email protected]
37+
with:
38+
ssh-private-key: ${{ secrets.SSH_PRIVATE_DEPLOY_KEY }}
39+
if: github.event_name != 'pull_request' && steps.changes.outputs.src == 'true'
40+
41+
- name: Prepare Git setting, commit & push
42+
run: |
43+
# `actions/checkout`が設定した`url.https://github.com/.insteadOf`を消しておく。
44+
# https://github.com/actions/checkout/blob/9a9194f87191a7e9055e3e9b95b8cfb13023bb08/adrs/0153-checkout-v2.md?plain=1#L261
45+
git submodule foreach --recursive git config --local --unset-all 'url.https://github.com/.insteadOf'
46+
cd public
47+
git config --local user.email "[email protected]"
48+
git config --local user.name "YOSHIMURA Yuu"
49+
git remote set-url origin [email protected]:urandom-ctf/urandom-ctf.github.io.git
50+
git add --all
51+
git commit -m 'Update website'
52+
git push origin master
53+
if: github.event_name != 'pull_request' && steps.changes.outputs.src == 'true'

0 commit comments

Comments
 (0)