Deploy to PRODUCTION #64
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: Deploy | |
run-name: Deploy to ${{ inputs.deploy_env }} | |
on: | |
workflow_dispatch: | |
inputs: | |
git_ref: | |
default: latest | |
required: true | |
description: Deploy version | |
deploy_env: | |
type: choice | |
default: PRODUCTION | |
description: Deploy enviroment | |
options: | |
- PRODUCTION | |
restart_app: | |
type: boolean | |
default: true | |
description: Restart app | |
jobs: | |
deploy: | |
name: Deploy To ${{ github.event.inputs.deploy_env }} | |
runs-on: [self-hosted, linux, x64, "${{ github.event.inputs.deploy_env }}"] | |
steps: | |
- name: Deploy | |
uses: actions/checkout@v3 | |
if: github.event.inputs.git_ref == 'latest' | |
- name: Rollback | |
uses: actions/checkout@v3 | |
if: github.event.inputs.git_ref != 'latest' | |
with: | |
ref: ${{ github.event.inputs.git_ref }} | |
- name: Install dependencies | |
run: npm i | |
- name: Build hugo | |
run: hugo | |
- name: ${{ github.event.inputs.deploy_env }} app restart | |
run: | | |
if [ ${{ github.event.inputs.restart_app }} == true ]; then | |
pm2 restart BLOG --log-date-format 'DD-MM-YYYY HH:mm:ss' | |
fi | |
- name: Notify deployment | |
run: DEPLOY_ENV=${{ github.event.inputs.deploy_env}} NTFY_USER=${{ secrets.NTFY_USER }} NTFY_PASSWD=${{ secrets.NTFY_PASSWD }} NTFY_SERVER_URL=${{ secrets.NTFY_SERVER_URL }} PROJECT_NAME=${{ vars.PROJECT_NAME }} npm run notify:deploy |