-
Notifications
You must be signed in to change notification settings - Fork 2
79 lines (71 loc) · 2.47 KB
/
deploy-prod.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
name: deploy-prod
on:
release:
types: [published]
workflow_dispatch:
concurrency:
group: "deploy"
cancel-in-progress: false
jobs:
deploy:
environment: prod-aws-folclore
runs-on: ubuntu-latest
steps:
- name: 'Check out repository'
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: 'Install Python requests'
run: pip install requests
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
build-args: |
APP_VERSION=${{github.ref_name}}
push: ${{ github.event_name != 'pull_request' }}
tags: eduardoferro/capivara:${{ github.sha }},${{ github.event_name == 'release' && format('eduardoferro/capivara:latest,eduardoferro/capivara:{0}', github.ref_name) || '' }}
- name: 'Wait for host'
run: |
SLEEP=1
TRIES=0
MAX_TRIES=10
while ! nc -w5 -z $INSTANCE_IP 9443; do
echo "SSH not available..."
if [[ $TRIES -eq $MAX_TRIES ]]; then
echo "Max tries reached, exiting"
exit 1
fi
((TRIES += 1))
sleep $SLEEP
done; echo "Host ready!"
env:
INSTANCE_IP: ${{ secrets.INSTANCE_IP }}
- name: 'Deploy to Portainer'
working-directory: ./.ci
run: |
python3 ./deploy.py
env:
# Portainer
PORTAINER_HOST: ${{ secrets.PORTAINER_HOST }}
PORTAINER_ENDPOINT_ID: ${{ secrets.PORTAINER_ENDPOINT_ID }}
PORTAINER_ACCESS_TOKEN: ${{ secrets.PORTAINER_ACCESS_TOKEN }}
# Image
CAPIVARA_IMAGE_TAG: ${{ github.sha }}
# Bot
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
LOG_CHANNEL_ID: ${{ secrets.DISCORD_LOG_CHANNEL_ID }}
CURUPIRA_RESET: 'true'
DATABASE_DRIVER: 'org.postgresql.Driver'
DATABASE_DIALECT: 'org.hibernate.dialect.PostgreSQL95Dialect'
DATABASE_URL: 'jdbc:postgresql://postgres-db:5432/capivara'
DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
JAVA_ARGS: '-Xmx350M'