OSDN Git Service

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