Update pnpm lock #105
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - '.github/workflows/deploy-prod.yml' | |
| - '.justfile' | |
| - 'docker-compose.prod.yml' | |
| - 'server/**' | |
| - 'server/Dockerfile.toolchain' | |
| - 'web/**' | |
| - '!**/*.md' | |
| - '!**/docs/**' | |
| workflow_dispatch: | |
| concurrency: | |
| group: deploy-main | |
| cancel-in-progress: true | |
| env: | |
| REGISTRY: ghcr.io | |
| SERVER_IMAGE: ghcr.io/touhoucloudmusic/thcdb-server | |
| WEB_IMAGE: ghcr.io/touhoucloudmusic/thcdb-web | |
| RUST_BUILDER_IMAGE: ghcr.io/touhoucloudmusic/thcdb-rust-builder | |
| WILD_LINKER_IMAGE: ghcr.io/touhoucloudmusic/thcdb-wild-linker-builder | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-images: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Build rust builder image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: server | |
| file: server/Dockerfile.toolchain | |
| target: rust-builder | |
| push: true | |
| tags: | | |
| ${{ env.RUST_BUILDER_IMAGE }}:${{ github.sha }} | |
| ${{ env.RUST_BUILDER_IMAGE }}:main | |
| cache-from: type=gha,scope=rust-builder | |
| cache-to: type=gha,scope=rust-builder,mode=max | |
| - name: Build wild linker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: server | |
| file: server/Dockerfile.toolchain | |
| target: wild-linker-builder | |
| push: true | |
| tags: | | |
| ${{ env.WILD_LINKER_IMAGE }}:${{ github.sha }} | |
| ${{ env.WILD_LINKER_IMAGE }}:main | |
| cache-from: type=gha,scope=wild-linker-builder | |
| cache-to: type=gha,scope=wild-linker-builder,mode=max | |
| - name: Build server image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: server | |
| file: server/Dockerfile.prod | |
| push: true | |
| tags: | | |
| ${{ env.SERVER_IMAGE }}:${{ github.sha }} | |
| ${{ env.SERVER_IMAGE }}:main | |
| build-args: | | |
| RUST_BUILDER_IMAGE=${{ env.RUST_BUILDER_IMAGE }}:${{ github.sha }} | |
| WILD_LINKER_IMAGE=${{ env.WILD_LINKER_IMAGE }}:${{ github.sha }} | |
| cache-from: type=gha,scope=server-prod | |
| cache-to: type=gha,scope=server-prod,mode=max | |
| - name: Build web image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: web | |
| file: web/Dockerfile.prod | |
| push: true | |
| tags: | | |
| ${{ env.WEB_IMAGE }}:${{ github.sha }} | |
| ${{ env.WEB_IMAGE }}:main | |
| cache-from: type=gha,scope=web-prod | |
| cache-to: type=gha,scope=web-prod,mode=max | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build-images | |
| steps: | |
| - name: Deploy over SSH | |
| uses: appleboy/ssh-action@v1.2.5 | |
| with: | |
| host: ${{ secrets.DEPLOY_HOST }} | |
| port: ${{ secrets.DEPLOY_PORT }} | |
| username: ${{ secrets.DEPLOY_USER }} | |
| key: ${{ secrets.DEPLOY_SSH_KEY }} | |
| command_timeout: 30m | |
| script: | | |
| set -euo pipefail | |
| cd "$HOME/thcdb" | |
| git fetch origin main | |
| git reset --hard origin/main | |
| echo "${{ github.token }}" | docker login "${{ env.REGISTRY }}" -u "${{ github.actor }}" --password-stdin | |
| export IMAGE_TAG="${{ github.sha }}" | |
| export SERVER_IMAGE="${{ env.SERVER_IMAGE }}" | |
| export WEB_IMAGE="${{ env.WEB_IMAGE }}" | |
| docker compose -f docker-compose.prod.yml pull server web | |
| docker compose -f docker-compose.prod.yml up -d --remove-orphans | |
| docker logout "${{ env.REGISTRY }}" |