v3.2.0 #49
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3.2.0 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6.4.1 | |
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 SSH' | |
run: | | |
SLEEP=1 | |
TRIES=0 | |
MAX_TRIES=10 | |
while ! nc -w5 -z $INSTANCE_IP 22; 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 "SSH ready!" | |
env: | |
INSTANCE_IP: ${{ secrets.INSTANCE_IP }} | |
- name: 'Push start-container.sh' | |
uses: appleboy/scp-action@v0.1.7 | |
with: | |
host: ${{ secrets.INSTANCE_IP }} | |
username: ${{ secrets.SSH_USERNAME }} | |
passphrase: ${{ secrets.VM_SSH_PRIVATE_KEY_PASSPHRASE }} | |
key: ${{ secrets.VM_SSH_PRIVATE_KEY }} | |
source: "./start-container.sh" | |
target: /home/${{ secrets.SSH_USERNAME }}/capivara/ | |
strip_components: 1 | |
- name: 'Start BOT' | |
uses: appleboy/ssh-action@v0.1.7 | |
with: | |
host: ${{ secrets.INSTANCE_IP }} | |
username: ${{ secrets.SSH_USERNAME }} | |
passphrase: ${{ secrets.VM_SSH_PRIVATE_KEY_PASSPHRASE }} | |
key: ${{ secrets.VM_SSH_PRIVATE_KEY }} | |
script: | | |
cd /home/${{ secrets.SSH_USERNAME }}/capivara | |
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://capivara_database:5432/capivara' DATABASE_USERNAME='${{ secrets.DATABASE_USERNAME }}' DATABASE_PASSWORD='${{ secrets.DATABASE_PASSWORD }}' JAVA_ARGS='-Xmx350M' /bin/bash start-container.sh docker.io/eduardoferro/capivara:${{ github.sha }} |