From b45bc81ed674d56be893f27e36f2117961bbd12d Mon Sep 17 00:00:00 2001 From: hanshino Date: Fri, 18 Oct 2024 18:00:32 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=AA=BF=E6=95=B4=20cicd=20=E6=A9=9F?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 26 +++++++++++++++++++++++++- scripts/traefik-run/001_run.sh | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 86e45ab6..4af8dccc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,8 @@ on: - main jobs: - docker: + # Backend build and push job + backend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -32,6 +33,24 @@ jobs: cache-from: type=registry,ref=hanshino/redive_backend:buildcache cache-to: type=registry,ref=hanshino/redive_backend:buildcache,mode=max + # Frontend build and push job, executed in parallel with backend + frontend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Frontend build and push Docker image uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 with: @@ -43,6 +62,11 @@ jobs: build-args: | REACT_APP_GOOGLE_ANALYTICS_ID=${{ secrets.GOOGLE_ANALYTICS_ID }} + # Deployment job, dependent on both backend and frontend build completion + deploy: + runs-on: ubuntu-latest + needs: [backend, frontend] # Ensure that both backend and frontend jobs are finished before deploying + steps: - name: Deploy Redive linebot uses: appleboy/ssh-action@v1.1.0 with: diff --git a/scripts/traefik-run/001_run.sh b/scripts/traefik-run/001_run.sh index 3d066aad..2bd43f62 100644 --- a/scripts/traefik-run/001_run.sh +++ b/scripts/traefik-run/001_run.sh @@ -3,4 +3,5 @@ "${COMPOSE_CMD[@]}" -f docker-compose.traefik.yml pull "${COMPOSE_CMD[@]}" -f docker-compose.traefik.yml build "${COMPOSE_CMD[@]}" -f docker-compose.traefik.yml up -d +"${COMPOSE_CMD[@]}" -f docker-compose.traefik.yml restart bot "${COMPOSE_CMD[@]}" -f docker-compose.traefik.yml exec -T bot yarn migrate