Skip to content

Fix build ci

Fix build ci #4

Workflow file for this run

name: Publish CI
on:
push:
branches:
- main
env:
REGISTRY: ghcr.io
APP_IMAGE_NAME: 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: Build and Push Docker image
uses: docker/build-push-action@v2
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
repository: "${{ env.REGISTRY }}/${{ env.APP_IMAGE_NAME }}"
tag_with_ref: true
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 -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ${{ env.REGISTRY }} &&
docker pull "${{ env.REGISTRY }}/${{ env.APP_IMAGE_NAME }}":latest &&
docker run -d --name ${{ env.APP_NAME }} -p 0.0.0.0:80:80 "${{ env.REGISTRY }}/${{ env.APP_IMAGE_NAME }}":latest