Skip to content

Commit 950b998

Browse files
s
1 parent 1f1c935 commit 950b998

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/scratch-workflow.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ jobs:
3838
- name: 'Docker auth'
3939
run: |-
4040
gcloud auth configure-docker us-west1-docker.pkg.dev
41+
42+
- name: Configure SSH
43+
run: |
44+
mkdir -p ~/.ssh/
45+
echo "${{ secrets.GCP_SSH_PRIVATE_KEY }}" > ~/.ssh/private.key
46+
chmod 600 ~/.ssh/private.key
47+
echo "${{ secrets.GCP_SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts
4148
4249
- name: Build Docker image
4350
id: build
@@ -55,3 +62,24 @@ jobs:
5562
NEXT_PUBLIC_SENTRY_ENVIRONMENT=${{ vars.NEXT_PUBLIC_SENTRY_ENVIRONMENT }}
5663
NEXT_PUBLIC_SENTRY_WEBAPP_DSN=${{ vars.NEXT_PUBLIC_SENTRY_WEBAPP_DSN }}
5764
NEXT_PUBLIC_SENTRY_BACKEND_DSN=${{ vars.NEXT_PUBLIC_SENTRY_BACKEND_DSN }}
65+
66+
67+
- name: Deploy to GCP
68+
run: |
69+
ssh -i ~/.ssh/private.key ${{ secrets.GCP_USERNAME }}@${{ secrets.GCP_HOST }} << 'EOF'
70+
# First pull the new image
71+
docker pull ${{ env.IMAGE_PATH }}:${{ github.sha }}
72+
73+
# Stop and remove any existing container
74+
docker stop -t 60 sourcebot || true
75+
docker rm sourcebot || true
76+
77+
# Run the new container
78+
docker run -d \
79+
-p 80:3000 \
80+
--rm \
81+
--env-file .env \
82+
# -v /mnt/data:/data \
83+
--name sourcebot \
84+
${{ env.IMAGE_PATH }}:${{ github.sha }}
85+
EOF

0 commit comments

Comments
 (0)