Skip to content

Test actions commit

Test actions commit #6

Workflow file for this run

name: CD Pipeline
on:
push:
branches:
- action
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker image build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/backend:latest
build-args: |
DB_HOST: ${{ secrets.DB_HOST }}
DB_PORT: ${{ secrets.DB_PORT }}
DB_NAME: ${{ secrets.DB_NAME }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
- name: Set environment variables
run: |
echo "MYSQL_DATABASE=${{ secrets.DB_NAME }}" > .env
echo "MYSQL_ROOT_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env
- name: Deploy Application
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USERNAME }}
key: ${{ secrets.REMOTE_KEY }}
script: |
echo "### Change directory to Sasimee-Back ###"
cd /home/ubuntu/Backend
echo "### Pull origin main from github ###"
git pull origin main
echo "### Pull new image from dockerhub###"
sudo docker compose build backend
echo "### Shutdown existing container ###"
sudo docker compose down
echo "### Turn on new container ###"
sudo docker compose up -d