Skip to content

Update production-deployment.yaml #5

Update production-deployment.yaml

Update production-deployment.yaml #5

name: PROD DEPLOYMENT WITH TAG
on:
push:
branches:
- main
tags:
- 'v0.0.0'
jobs:
deploy:
#if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set TAG environment variable
id: get_tag
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Deploy Stack
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_NAME_PROD }}
username: ${{ secrets.USERNAME_PROD }}
key: ${{ secrets.SSH_KEY_PROD }}
port: ${{ secrets.PORT_PROD }}
script: |
TARGET_DIR="${{ secrets.TARGET_DIR_PROD }}"
ENVIRONMENT="$TARGET_DIR/.env"
if [ -f "$ENVIRONMENT" ]; then
rm "$ENVIRONMENT"
fi
mkdir -p "$TARGET_DIR"
cat << EOF > "$ENVIRONMENT"
${{ secrets.PROD_ENV }}
EOF
cd ${{ secrets.TARGET_DIR_PROD }}
#docker stop ${{ secrets.CONTAINER_NAME }}
#docker rm -f ${{ secrets.CONTAINER_NAME }}
#docker system prune -af
ls -ltra
./deploy.sh $TAG