Deploy #57
This file contains 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: | |
workflow_call: | |
inputs: | |
api: | |
required: true | |
type: boolean | |
crawler: | |
required: true | |
type: boolean | |
bot: | |
required: true | |
type: boolean | |
workflow_dispatch: | |
inputs: | |
api: | |
required: true | |
type: boolean | |
crawler: | |
required: true | |
type: boolean | |
bot: | |
required: true | |
type: boolean | |
schedule: | |
- cron: '30 4 * * 0' | |
jobs: | |
deploy-api: | |
name: Deploy api | |
if: ${{ inputs.api || 'false' }} | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Deploy api | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ vars.SSH_HOST_API }} | |
username: ${{ vars.SSH_USER }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
docker compose pull && | |
docker compose --ansi never up -d --force-recreate api | |
deploy-crawler: | |
name: Deploy crawler | |
if: ${{ inputs.crawler || 'false' }} | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Deploy crawler | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ vars.SSH_HOST_CRAWLER }} | |
username: ${{ vars.SSH_USER }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
docker compose pull && | |
touch migration-state.json && | |
docker compose --ansi never run --rm crawler npm run db:migrate && | |
docker compose --ansi never up -d --force-recreate crawler | |
deploy-bot: | |
name: Deploy bot shards | |
if: ${{ inputs.bot || 'true' }} | |
runs-on: ubuntu-latest | |
environment: production | |
strategy: | |
matrix: | |
shard: [0, 1, 2, 3] | |
include: | |
- shard: 0 | |
SSH_HOST: SSH_HOST_BOT_0 | |
- shard: 1 | |
SSH_HOST: SSH_HOST_BOT_1 | |
- shard: 2 | |
SSH_HOST: SSH_HOST_BOT_2 | |
- shard: 3 | |
SSH_HOST: SSH_HOST_BOT_3 | |
steps: | |
- name: Deploy bot shard '#${{ matrix.shard }}' | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ vars[matrix.SSH_HOST] }} | |
username: ${{ vars.SSH_USER }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
touch migration-state.json && | |
docker compose --ansi never up -d --pull always --force-recreate bot | |