|
47 | 47 | run: pnpm run lint |
48 | 48 | working-directory: ./frontend |
49 | 49 |
|
50 | | - build-and-deploy: |
| 50 | + build-image: |
51 | 51 | runs-on: ubuntu-latest |
52 | 52 | needs: lint |
53 | 53 | if: github.ref == 'refs/heads/main' |
|
56 | 56 | - name: Checkout repository |
57 | 57 | uses: actions/checkout@v4 |
58 | 58 |
|
59 | | - - name: Set up QEMU |
60 | | - uses: docker/setup-qemu-action@v2 |
61 | | - |
62 | 59 | - name: Set up Docker Buildx |
63 | 60 | uses: docker/setup-buildx-action@v2 |
64 | 61 |
|
|
75 | 72 | context: ./frontend |
76 | 73 | file: ./frontend/Dockerfile |
77 | 74 | push: true |
78 | | - platforms: linux/amd64,linux/arm64 |
| 75 | + platforms: linux/amd64 |
79 | 76 | tags: | |
80 | 77 | ghcr.io/nctucsunion/pastexam:frontend |
81 | 78 | ghcr.io/nctucsunion/pastexam:frontend-${{ github.sha }} |
|
90 | 87 | context: ./backend |
91 | 88 | file: ./backend/Dockerfile |
92 | 89 | push: true |
93 | | - platforms: linux/amd64,linux/arm64 |
| 90 | + platforms: linux/amd64 |
94 | 91 | tags: | |
95 | 92 | ghcr.io/nctucsunion/pastexam:backend |
96 | 93 | ghcr.io/nctucsunion/pastexam:backend-${{ github.sha }} |
97 | 94 | cache-from: type=registry,ref=ghcr.io/nctucsunion/pastexam:backend-buildcache |
98 | 95 | cache-to: type=registry,ref=ghcr.io/nctucsunion/pastexam:backend-buildcache,mode=max |
| 96 | + |
| 97 | + deploy: |
| 98 | + runs-on: ubuntu-latest |
| 99 | + needs: build-image |
| 100 | + if: github.ref == 'refs/heads/main' |
| 101 | + |
| 102 | + steps: |
| 103 | + - name: Deploy via SSH |
| 104 | + uses: appleboy/ssh-action@v1.0.3 |
| 105 | + with: |
| 106 | + host: ${{ secrets.DEPLOY_HOST }} |
| 107 | + username: ${{ secrets.DEPLOY_USER }} |
| 108 | + key: ${{ secrets.DEPLOY_KEY }} |
| 109 | + script: | |
| 110 | + cd ${{ secrets.DEPLOY_DIRECTORY }} |
| 111 | + if [ -n "${{ secrets.GHCR_TOKEN }}" ]; then |
| 112 | + echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u "${{ secrets.GHCR_USERNAME }}" --password-stdin |
| 113 | + fi |
| 114 | + docker compose pull |
| 115 | + docker compose up -d |
0 commit comments