OSDN Git Service

[fix] : Run deploy on other jobs
[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         #run: hugo --minify -D
25
26       - name: Deploy for fascode.net
27         uses: peaceiris/actions-gh-pages@v3
28         with:
29           github_token: ${{ secrets.GITHUB_TOKEN }}
30           publish_branch: public
31           publish_dir: ./
32
33       - name: Build for GitHub Pages
34         run: bash ./update-blog.sh --baseURL https://hayao0819.github.io/hayao.fascode.net/blog/
35         #run: hugo --minify -D
36
37       - name: Deploy for GitHub Pages
38         uses: peaceiris/actions-gh-pages@v3
39         with:
40           github_token: ${{ secrets.GITHUB_TOKEN }}
41           publish_branch: gh-pages
42           publish_dir: ./
43
44   main-repo:
45     runs-on: ubuntu-latest
46     steps:
47       - name: Checkout
48         uses: actions/checkout@v2
49         with:
50           submodules: true
51           fetch-depth: 0 
52       
53       - name: Setup git repogitories
54         env:
55           GH_PAGES_REPO_DEPLOY_KEY: ${{ secrets.GH_PAGES_REPO_DEPLOY_KEY }}
56         run: |
57           echo "$GH_PAGES_REPO_DEPLOY_KEY" > ~/deploy_key.pem
58           chmod 600 ~/deploy_key.pem
59           git config --global user.email "hayao@fascode.net"
60           git config --global user.name "hayao"
61           git config remote.origin.url "git@github.com:Hayao0819/hayao0819.github.io.git"
62           git checkout gh-pages
63
64       - name: Deploy pages
65         env:
66           GIT_SSH_COMMAND: ssh -i ~/deploy_key.pem -o StrictHostKeyChecking=no -F /dev/null
67         run: |
68           git add -A
69           if ! git diff --cached --quiet; then
70             git commit -m "Deploy $GITHUB_SHA by GitHub Actions"
71             git pull origin master
72             git push origin master
73           fi
74