Skip to content

deploy-prod

deploy-prod #55

Workflow file for this run

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_BOT_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:5432/capivara'
DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
JAVA_ARGS: '-Xmx350M'