Update dependency @hey-api/openapi-ts to v0.96.1 #108
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: &rust_builder_image ghcr.io/touhoucloudmusic/thcdb-rust-builder | |
| WILD_LINKER_IMAGE: &wild_linker_image ghcr.io/touhoucloudmusic/thcdb-wild-linker-builder | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-toolchain-images: | |
| name: Build ${{ matrix.name }} image | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: rust builder | |
| target: rust-builder | |
| image: *rust_builder_image | |
| cache_scope: rust-builder | |
| - name: wild linker | |
| target: wild-linker-builder | |
| image: *wild_linker_image | |
| cache_scope: wild-linker-builder | |
| steps: | |
| - &checkout | |
| uses: actions/checkout@v6 | |
| - &setup_buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - &docker_login | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Build ${{ matrix.name }} image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: server | |
| file: server/Dockerfile.toolchain | |
| target: ${{ matrix.target }} | |
| push: true | |
| tags: | | |
| ${{ matrix.image }}:${{ github.sha }} | |
| ${{ matrix.image }}:main | |
| cache-from: type=gha,scope=${{ matrix.cache_scope }} | |
| cache-to: type=gha,scope=${{ matrix.cache_scope }},mode=max | |
| build-server-image: | |
| runs-on: ubuntu-latest | |
| needs: build-toolchain-images | |
| steps: | |
| - *checkout | |
| - *setup_buildx | |
| - *docker_login | |
| - 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 | |
| build-web-image: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - *checkout | |
| - *setup_buildx | |
| - *docker_login | |
| - 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-server-image | |
| - build-web-image | |
| 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 }}" |