-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (69 loc) · 3.05 KB
/
back.yaml
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# This is a basic workflow to help you get started with Actions
name: Continous Integration For Backend
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
paths:
- "back/**"
- .github/workflows/back.yaml
- ./package.json
- ./pnpm-lock.yaml
- Dockerfile.api
- docker-compose.prod.yaml
branches:
- main
# Allows you to run this workflow manually from the Actions tab+1
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-push-docker:
runs-on: ubuntu-latest
environment: prod
steps:
- uses: actions/checkout@v2
- uses: whoan/docker-build-with-cache-action@v5
with:
username: "${{ secrets.DCR_USER }}"
password: "${{ secrets.DCR_PASSWD }}"
image_name: kisscam-api
image_tag: latest
push_git_tag: true
build_extra_args: "--build-arg=SUPABASE_URL=${{ secrets.SUPABASE_URL }} --build-arg=SUPABASE_SERVICE_ROLE_KEY=${{ secrets.SUPABASE_SERVICE_ROLE_KEY }} --build-arg=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }} --build-arg=STRIPE_PUBLIC_KEY=${{ secrets.STRIPE_PUBLIC_KEY }} --build-arg=STRIPE_SECRET_KEY=${{ secrets.STRIPE_SECRET_KEY }} --build-arg=STRIPE_WEBHOOK_SECRET=${{ secrets.STRIPE_WEBHOOK_SECRET }} --build-arg=STRIPE_SUBSCRIPTION_ID=${{ secrets.STRIPE_SUBSCRIPTION_ID }} --build-arg=PAYMENT_REDIRECT_HOST=${{ secrets.PAYMENT_REDIRECT_HOST }}"
registry: dcr.fredkiss.dev
dockerfile: Dockerfile.api
context: .
deploy:
# The type of runner that the job will run on
needs:
- build-push-docker
runs-on: ubuntu-latest
environment: prod
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_SERVER_KEY }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Deploy to Server
run: |
rsync -arvzP -e "ssh -p $DEPLOY_PORT" ./docker-compose.prod.yaml $DEPLOY_USER@$DEPLOY_DOMAIN:$DEPLOY_DIR/back
ssh -p ${{ secrets.DEPLOY_PORT }} $DEPLOY_USER@$DEPLOY_DOMAIN "
echo $DCR_PASSWD | docker login --username=$DCR_USER --password-stdin dcr.fredkiss.dev
set -e # ignore errors
cd $DEPLOY_DIR/back
docker-compose -f docker-compose.prod.yaml down || true
docker-compose -f docker-compose.prod.yaml rm -f || true
docker-compose -f docker-compose.prod.yaml pull
docker-compose -f docker-compose.prod.yaml up -d
"
env:
DEPLOY_DIR: ${{ secrets.DEPLOY_DIR }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
DEPLOY_DOMAIN: ${{ secrets.DEPLOY_DOMAIN }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DCR_PASSWD: ${{ secrets.DCR_PASSWD }}
DCR_USER: ${{ secrets.DCR_USER }}