fixes referenced issues #46
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: CI/CD | |
# on: | |
# push: | |
# branches: | |
# - "*" | |
# pull_request: | |
# env: | |
# IMAGE_NAME: "project_badging" | |
# jobs: | |
# deploy: | |
# 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 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: 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 load -i ~/badging.tar | |
# docker run -d \ | |
# -p ${{ secrets.PORT }}:${{ secrets.PORT }} \ | |
# --env-file /home/${{ secrets.USERNAME }}/.env \ | |
# --restart=always \ | |
# --name ${{ env.IMAGE_NAME }} \ | |
# ${{ env.IMAGE_NAME }}:${{ github.sha }} | |
name: Node.js CI/CD | |
on: | |
push: | |
branches: | |
- "*" | |
pull_request: | |
env: | |
DEPLOY_FOLDER: "project-badging-backend" | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Cleanup existing content on the server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
script: | | |
if [ -d ./${{ env.DEPLOY_FOLDER }} ]; then | |
cd ./${{ env.DEPLOY_FOLDER }} | |
find . -maxdepth 1 -type f ! -name '.env' -exec rm -f {} + | |
else | |
mkdir -p ./${{ env.DEPLOY_FOLDER }} | |
fi | |
- name: Upload repository contents to the server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
source: ./ | |
target: ./${{ env.DEPLOY_FOLDER }}/ |