-
-
Notifications
You must be signed in to change notification settings - Fork 3
61 lines (56 loc) · 1.71 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: CI
on:
push:
branches: [ "main" ]
paths-ignore:
- '**/*.md'
- 'Makefile'
- '.gitignore'
concurrency:
group: ci
cancel-in-progress: true
jobs:
test:
name: Tests
uses: ./.github/workflows/test.yml
build:
name: Build & Push Image
runs-on: ubuntu-latest
needs: [ test ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GCP Artifact Registry
uses: docker/login-action@v2
with:
registry: us-central1-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCP_AR_KEY }}
- name: Build & Push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/docker/toru-prod:${{ github.sha }}
us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/docker/toru-prod:latest
build-args: |
LFM_TOKEN=${{ secrets.LFM_TOKEN }}
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: [ build ]
steps:
- name: Deploy to VPS
uses: appleboy/ssh-action@master
with:
host: ${{ vars.SSH_HOST }}
username: ${{ vars.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
docker pull us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/docker/toru-prod:latest
docker stop toru-prod || true
docker rm toru-prod || true
docker run -d --rm --name toru-prod -p 8080:8080 -e PORT=8080 us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/docker/toru-prod:latest