OSDN Git Service

[fix] : allow-unrelated-histories
[alterlinux/hayao.fascode.net.git] / .github / workflows / hugo.yaml
index 75afa96..ba213fa 100644 (file)
@@ -21,7 +21,6 @@ jobs:
 
       - name: Build for fascode.net
         run: bash ./update-blog.sh
-        #run: hugo --minify -D
 
       - name: Deploy for fascode.net
         uses: peaceiris/actions-gh-pages@v3
@@ -32,7 +31,6 @@ jobs:
 
       - name: Build for GitHub Pages
         run: bash ./update-blog.sh --baseURL https://hayao0819.github.io/hayao.fascode.net/blog/
-        #run: hugo --minify -D
 
       - name: Deploy for GitHub Pages
         uses: peaceiris/actions-gh-pages@v3
@@ -49,17 +47,6 @@ jobs:
         with:
           submodules: true
           fetch-depth: 0 
-      
-      - name: Setup git repogitories
-        env:
-          GH_PAGES_REPO_DEPLOY_KEY: ${{ secrets.GH_PAGES_REPO_DEPLOY_KEY }}
-        run: |
-          echo "$GH_PAGES_REPO_DEPLOY_KEY" > ~/deploy_key.pem
-          chmod 600 ~/deploy_key.pem
-          git config --global user.email "hayao@fascode.net"
-          git config --global user.name "hayao"
-          git config pull.rebase false
-          git config remote.origin.url "git@github.com:Hayao0819/hayao0819.github.io.git"
 
       - name: Setup
         uses: peaceiris/actions-hugo@v2
@@ -69,16 +56,31 @@ jobs:
 
       - name: Build for GitHub Pages
         run: bash ./update-blog.sh --baseURL https://hayao0819.github.io/blog/
-        #run: hugo --minify -D
 
-      - name: Deploy pages
-        env:
-          GIT_SSH_COMMAND: ssh -i ~/deploy_key.pem -o StrictHostKeyChecking=no -F /dev/null
+      - name: Install SSH key
+        uses: shimataro/ssh-key-action@v2
+        with:
+          key: ${{ secrets.GH_PAGES_REPO_DEPLOY_KEY }}
+          name: id_rsa # optional
+          known_hosts: unnecessary
+
+      - name: Commit files
+        env: 
+          GH_PAGES_REPO_DEPLOY_KEY: ${{ secrets.GH_PAGES_REPO_DEPLOY_KEY }}
         run: |
+          echo "$GH_PAGES_REPO_DEPLOY_KEY" > ~/deploy_key.pem
+          chmod 600 ~/deploy_key.pem
+          git config --local user.email "hayao@fascode.net"
+          git config --local user.name "hayao[bot]"
+          git config pull.rebase false
+          git config remote.origin.url "git@github.com:hayao0819/hayao0819.github.io.git"
+          echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
           git add -A
           if ! git diff --cached --quiet; then
-            git commit -m "Deploy $GITHUB_SHA by GitHub Actions"
-            git pull origin master
-            git push origin master
+            git commit -m "deploy: ${GITHUB_SHA}" -a
+          else
+            echo "Nothing has been commited"
           fi
-
+          git pull --allow-unrelated-histories origin master
+          git push origin master
+