Skip to content

CI/CD using github actions & docker #152

CI/CD using github actions & docker

CI/CD using github actions & docker #152

Workflow file for this run

name: CI/CD using github actions & docker
on:
push:
branches:
- master
schedule:
- cron: "*/180 * * * *"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "18"
- name: Install dependencies
run: |
npm install
- name: Install Redis
run: |
sudo apt-get update
sudo apt-get install -y redis-server
- name: Build Docker image
run: docker build -t jeongseho1/heatpick-notification:latest .
- name: Login to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker image to Docker Hub
run: docker push jeongseho1/heatpick-notification:latest
- name: SSH into Ubuntu server and pull the latest image
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker pull jeongseho1/heatpick-notification
docker stop heatpick-notification-container || true
docker rm heatpick-notification-container || true
docker run -e SSH_HOST=${{ secrets.SSH_HOST }} -e SSH_PORT=${{ secrets.SSH_PORT }} -e SSH_USER=${{ secrets.SSH_USER }} -e SSH_PASSWORD=${{ secrets.SSH_PASSWORD }} -e DB_HOST=${{ secrets.DB_HOST }} -e DB_USER_NAME=${{ secrets.DB_USER_NAME }} -e DB_USER_PASSWORD=${{ secrets.DB_USER_PASSWORD }} -e DB_NAME=${{ secrets.DB_NAME }} -e SA_TYPE=${{ secrets.SA_TYPE }} -e SA_PROJECT_ID=${{ secrets.SA_PROJECT_ID }} -e SA_PRIVATE_KEY_ID=${{ secrets.SA_PRIVATE_KEY_ID }} -e SA_CLIENT_EMAIL=${{ secrets.SA_CLIENT_EMAIL }} -e SA_CLIENT_ID=${{ secrets.SA_CLIENT_ID }} -e SA_AUTH_URI=${{ secrets.SA_AUTH_URI }} -e SA_TOKEN_URI=${{ secrets.SA_TOKEN_URI }} -e SA_AUTH_PROVIDER_CERT_URL=${{ secrets.SA_AUTH_PROVIDER_CERT_URL }} -e SA_CLIENT_CERT_URL=${{ secrets.SA_CLIENT_CERT_URL }} -e SA_UNIVERSE_DOMAIN=${{ secrets.SA_UNIVERSE_DOMAIN }} -d -p 3000:3000 --name heatpick-notification-container jeongseho1/heatpick-notification