OSDN Git Service

[update] : タイトル書き換えを追加
[alterlinux/hayao.fascode.net.git] / .github / workflows / hugo.yaml
1 # このGitHub Actionsはhayao0819/hayao.fascode.net上でのみ実行されます
2 name: Hugo Build and Deploy
3
4 on: 
5   push:
6     branches:
7       - main
8       - master
9
10 jobs:
11   # このjobはこのリポジトリのpublicとgh-pagesリポジトリにデプロイします
12   gh-pages:
13     runs-on: ubuntu-latest
14     steps:
15       - name: Checkout
16         uses: actions/checkout@v2
17         with:
18           submodules: true
19           fetch-depth: 0 
20
21       # https://github.com/marketplace/actions/github-pages-action
22       - name: Setup
23         uses: peaceiris/actions-hugo@v2
24         with:
25           hugo-version: '0.88.1'
26           extended: true
27
28       - name: Build for fascode.net
29         run: bash ./update-blog.sh
30
31       - name: Deploy for fascode.net
32         uses: peaceiris/actions-gh-pages@v3
33         with:
34           github_token: ${{ secrets.GITHUB_TOKEN }}
35           publish_branch: public
36           publish_dir: ./
37
38       - name: Build for GitHub Pages
39         run: bash ./update-blog.sh --baseURL https://hayao0819.github.io/hayao.fascode.net/blog/
40
41       - name: Deploy for GitHub Pages
42         uses: peaceiris/actions-gh-pages@v3
43         with:
44           github_token: ${{ secrets.GITHUB_TOKEN }}
45           publish_branch: gh-pages
46           publish_dir: ./
47
48   # このjobはhayao0819/hayao0819.github.ioにリポジトリをミラーします
49   mirror-repo:
50     runs-on: ubuntu-latest
51     if: github.repository == 'hayao0819/hayao.fascode.net'
52     steps:
53       - name: Checkout
54         uses: actions/checkout@v2
55         with:
56           submodules: true
57           fetch-depth: 0 
58
59       - name: Install SSH key
60         uses: shimataro/ssh-key-action@v2
61         with:
62           key: ${{ secrets.GH_PAGES_REPO_DEPLOY_KEY }}
63           name: id_rsa # optional
64           known_hosts: unnecessary
65
66       - name: Commit files to hayao0819.github.io
67         env: 
68           GH_PAGES_REPO_DEPLOY_KEY: ${{ secrets.GH_PAGES_REPO_DEPLOY_KEY }}
69         run: |
70           echo "$GH_PAGES_REPO_DEPLOY_KEY" > ~/deploy_key.pem
71           chmod 600 ~/deploy_key.pem
72           git config --local user.email "hayao@fascode.net"
73           git config --local user.name "hayao[bot]"
74           git config pull.rebase false
75           git config remote.origin.url "git@github.com:hayao0819/hayao0819.github.io.git"
76           echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
77           git add -A
78           git checkout -b mirror
79           git pull --allow-unrelated-histories origin mirror
80           git push --force origin mirror
81