OSDN Git Service

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