-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (76 loc) · 3.05 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Continuous Integration and Continuous Deployment
on:
push:
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-push-image-and-deploy-stack:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ghcr.io/${{ github.repository_owner }}/navaship:latest
- name: Checkout the repo
uses: actions/checkout@v3
with:
# This will create a directory named `api` and copy the repo contents to it
# so that you can easily upload it to your remote server
path: api
ref: main
- name: Copy repo to remote server
uses: appleboy/scp-action@master
with:
host: ${{ vars.VPS_HOST }}
port: ${{ vars.VPS_PORT }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
source: api
target: "~/navaship"
- name: SSH and Deploy
uses: appleboy/[email protected]
with:
host: ${{ vars.VPS_HOST }}
port: ${{ vars.VPS_PORT }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
script: |
cd ~/navaship/api
docker-compose -f docker-compose.prod.yml down
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
export SPRING_PROFILES_ACTIVE="prod"
export DATABASE_NAME="${{ vars.DATABASE_NAME }}"
export DATABASE_USER="${{ vars.DATABASE_USER }}"
export DATABASE_PASSWORD="${{ secrets.DATABASE_PASSWORD }}"
export API_PORT="${{ vars.API_PORT }}"
export API_DOMAIN="${{ vars.API_DOMAIN }}"
export WEBAPP_URL="${{ vars.WEBAPP_URL }}"
export SENDGRID_SENDER_EMAIL="${{ vars.SENDGRID_SENDER_EMAIL }}"
export SENDGRID_APIKEY="${{ secrets.SENDGRID_APIKEY }}"
export EASYPOST_APIKEY="${{ secrets.EASYPOST_APIKEY }}"
export EASYPOST_WEBHOOK_ENDPOINT_URL="${{ vars.EASYPOST_WEBHOOK_ENDPOINT_URL }}"
export STRIPE_APIKEY="${{ secrets.STRIPE_APIKEY }}"
export STRIPE_WEBHOOK_ENDPOINT_URL="${{ vars.STRIPE_WEBHOOK_ENDPOINT_URL }}"
export STRIPE_PRODUCT_ID="${{ vars.STRIPE_PRODUCT_ID }}"
docker-compose -f docker-compose.prod.yml pull
docker-compose -f docker-compose.prod.yml up -d