GCP Deploy (staging) #16
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: GCP Deploy (staging) | |
on: | |
workflow_run: | |
workflows: ["Publish to ghcr (staging)"] | |
types: | |
- completed | |
jobs: | |
deploy: | |
name: Deploy staging app to GCP | |
runs-on: ubuntu-latest | |
steps: | |
- name: Configure SSH | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "${{ secrets.GCP_STAGING_SSH_PRIVATE_KEY }}" > ~/.ssh/private.key | |
chmod 600 ~/.ssh/private.key | |
echo "${{ secrets.GCP_STAGING_SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts | |
- name: Deploy to GCP | |
run: | | |
ssh -i ~/.ssh/private.key ${{ secrets.GCP_STAGING_USERNAME }}@${{ secrets.GCP_STAGING_HOST }} << 'EOF' | |
# Stop and remove any existing container | |
docker stop sourcebot-staging || true | |
docker rm sourcebot-staging || true | |
# Run new container | |
docker run -d \ | |
-p 80:3000 \ | |
--pull always \ | |
--env-file .env.staging \ | |
-v /mnt/data:/data \ | |
--name sourcebot-staging \ | |
ghcr.io/sourcebot-dev/sourcebot:staging | |
EOF |