Missing and operator #15
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: Publish CI | |
on: | |
push: | |
branches: | |
- main | |
permissions: write-all | |
env: | |
REGISTRY: ghcr.io | |
APP_IMAGE_NAME: rafaellevissa/bnb-bank-api | |
APP_NAME: bnb-bank-api | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Login to GitHub Registry | |
if: success() | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.APP_IMAGE_NAME }}:latest | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build-and-push | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: SSH to EC2 and deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_SSH_PRIVATE_KEY }} | |
script: | | |
docker login ${{ env.REGISTRY }} -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} && | |
docker pull ${{ env.REGISTRY }}/${{ env.APP_IMAGE_NAME }}:latest && | |
docker inspect ${{ env.APP_NAME }} &> /dev/null && docker rm -f ${{ env.APP_NAME }} || true && | |
docker run -d --name ${{ env.APP_NAME }} -p 8080:80 --env-file=/opt/bnb-bank/.env-backend --network bnb-bank ${{ env.REGISTRY }}/${{ env.APP_IMAGE_NAME }}:latest |