Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

changed deploy configs #34

changed deploy configs

changed deploy configs #34

Workflow file for this run

name: CI/CD
on:
push:
branches:
- "*"
pull_request:
env:
IMAGE_NAME: "event_badging"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: npm install
- name: Lint code
run: npm run format
deploy:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- name: Build Docker image
run: docker build -t ${{ env.IMAGE_NAME }}:${{ github.sha }} .
- name: Create image archive
run: docker save ${{ env.IMAGE_NAME }}:${{ github.sha }} -o event_badging.tar
- name: Upload image archive using appleboy/scp-action
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
source: event_badging.tar
target: ~/
- name: Extract and load image on droplet
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
if docker inspect ${{ env.IMAGE_NAME }} >/dev/null 2>&1; then
docker stop ${{ env.IMAGE_NAME }}
docker rm ${{ env.IMAGE_NAME }}
fi
docker rmi -f $(docker images -q ${{ env.IMAGE_NAME }}) || true
docker load -i ~/event_badging.tar
docker run -d \
-p ${{ secrets.PORT }}:${{ secrets.PORT }} \
--env-file /home/${{ secrets.USERNAME }}/.env.badging_bot \
--restart=always \
--name ${{ env.IMAGE_NAME }} \
${{ env.IMAGE_NAME }}:${{ github.sha }}