ソースを参照

CI: Parallel Step

SukkaW 2 日 前
コミット
79545a3a6b
1 ファイル変更29 行追加35 行削除
  1. 29 35
      .github/workflows/main.yml

+ 29 - 35
.github/workflows/main.yml

@@ -144,10 +144,10 @@ jobs:
           GH_USER: ${{ secrets.GIT_USER }}
           GH_TOKEN: ${{ secrets.GIT_TOKEN }}
 
-  deploy_to_cloudflare_pages:
+  deploy:
     needs:
       - build
-    name: Deploy to Cloudflare Pages
+    name: Deploy
     if: github.ref == 'refs/heads/master'
     runs-on: ubuntu-slim
     # matrix is a tricky way to define a variable directly in the action yaml
@@ -171,58 +171,51 @@ jobs:
         with:
           name: build-artifact-${{ github.sha }}-${{ github.run_number }}
           path: public
-      - uses: cloudflare/wrangler-action@v3
+      - name: Prepare GitHub Pages deployment marker
+        id: deploy_marker
+        run: |
+          echo "marker_file=deploy-check-${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}.txt" >> $GITHUB_OUTPUT
+      # Deploy to Cloudflare, GitLab, and GitHub in parallel
+      - name: Deploy to Cloudflare Pages
+        id: deploy_cloudflare
+        uses: cloudflare/wrangler-action@v3
+        background: true
         with:
           apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
           accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
           command: pages deploy public --project-name=sukkaw-ruleset --commit-dirty=true --branch=main
           wranglerVersion: ${{ matrix.wranglerVersion }}
-
-  deploy_to_github_gitlab:
-    needs:
-      - build
-    name: Deploy to GitHub and GitLab
-    if: github.ref == 'refs/heads/master'
-    runs-on: ubuntu-slim
-    steps:
-      - uses: actions/download-artifact@v8
-        with:
-          name: build-artifact-${{ github.sha }}-${{ github.run_number }}
-          path: public
       - name: Upload Dist to GitLab
-        continue-on-error: true
+        id: deploy_gitlab
+        background: true
         run: |
-          git clone --filter=tree:0 --no-tags https://${GITLAB_TOKEN_NAME}:${GITLAB_TOKEN}@gitlab.com/SukkaW/ruleset.skk.moe.git ./deploy-git
-          cd ./deploy-git
-          git config --global push.dgefault matching
-          git config --global user.email "${GITLAB_EMAIL}"
-          git config --global user.name "${GITLAB_USER}"
+          git clone --filter=tree:0 --no-tags https://${GITLAB_TOKEN_NAME}:${GITLAB_TOKEN}@gitlab.com/SukkaW/ruleset.skk.moe.git ./deploy-git-gitlab
+          cd ./deploy-git-gitlab
+          git config push.default matching
+          git config user.email "${GITLAB_EMAIL}"
+          git config user.name "${GITLAB_USER}"
           rm -rf ./*
           cp -rf ../public/* ./
           git add --all .
           git commit -m "deploy: https://github.com/SukkaW/Surge/commit/${GITHUB_SHA}"
           git push --quiet --force origin HEAD:master
           cd ..
-          rm -rf ./deploy-git
+          rm -rf ./deploy-git-gitlab
         env:
           GITLAB_EMAIL: ${{ secrets.GITLAB_EMAIL }}
           GITLAB_USER: ${{ secrets.GITLAB_USER }}
           GITLAB_TOKEN_NAME: ${{ secrets.GITLAB_TOKEN_NAME }}
           GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
-      - name: Prepare GitHub Pages deployment marker
-        id: deploy_marker
-        run: |
-          echo "marker_file=deploy-check-${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}.txt" >> $GITHUB_OUTPUT
       - name: Upload Dist to GitHub
         id: upload_dist_to_github
-        continue-on-error: true
+        background: true
         run: |
           gh repo unarchive SukkaLab/ruleset.skk.moe --yes
-          git clone --filter=tree:0 --no-tags https://${GH_USER}:${GH_TOKEN}@github.com/SukkaLab/ruleset.skk.moe.git ./deploy-git
-          cd ./deploy-git
-          git config --global push.default matching
-          git config --global user.email "${GH_EMAIL}"
-          git config --global user.name "${GH_USER}"
+          git clone --filter=tree:0 --no-tags https://${GH_USER}:${GH_TOKEN}@github.com/SukkaLab/ruleset.skk.moe.git ./deploy-git-github
+          cd ./deploy-git-github
+          git config push.default matching
+          git config user.email "${GH_EMAIL}"
+          git config user.name "${GH_USER}"
           rm -rf ./*
           cp -rf ../public/* ./
           echo "ruleset-mirror.skk.moe" > CNAME
@@ -231,11 +224,12 @@ jobs:
           git commit -m "deploy: https://github.com/SukkaW/Surge/commit/${GITHUB_SHA}"
           git push --quiet --force origin HEAD:master
           cd ..
-          rm -rf ./deploy-git
+          rm -rf ./deploy-git-github
         env:
           GH_EMAIL: ${{ secrets.GIT_EMAIL }}
           GH_USER: ${{ secrets.GIT_USER }}
           GH_TOKEN: ${{ secrets.GIT_TOKEN }}
+      - wait: upload_dist_to_github
       - name: Wait for GitHub Pages to serve deployed marker
         if: steps.upload_dist_to_github.outcome == 'success'
         id: wait_for_github_pages
@@ -259,10 +253,10 @@ jobs:
           gh repo archive SukkaLab/ruleset.skk.moe --yes
         env:
           GH_TOKEN: ${{ secrets.GIT_TOKEN }}
+      - wait-all:
   remove_artifacts:
     needs:
-      - deploy_to_cloudflare_pages
-      - deploy_to_github_gitlab
+      - deploy
     name: Remove Artifacts after Deployment
     runs-on: ubuntu-slim
     steps: