Skip to content

feat: 🔨

feat: 🔨 #30

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: GitHub CI/CD (Auto Deploy)
on:
push:
branches: ['main']
pull_request:
branches: ['main']
types: ['closed']
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: 'Create env file'
run: |
echo "${{ secrets.ENV_FILE }}" > .env
- run: npm -g install [email protected]
- run: npm -g install pm2
- run: yarn install --frozen-lockfile
- run: yarn build:api
- name: 'Restart The Server'
run: pm2 restart server.aafiyah.com
- name: Send deployment success notification
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
# Server port, default 25:
server_port: 465
# Optional whether this connection use TLS (default is true if server_port is 465)
secure: true
# Optional (recommended) mail server username:
username: ${{secrets.EMAIL_USER}}
# Optional (recommended) mail server password:
password: ${{secrets.EMAIL_APP_PASSWORD}}
# Required mail subject:
subject: Aafiyah | Deployment Success
# Required recipients' addresses:
to: [email protected]
# Required sender full name (address can be skipped):
from: Hasib <${{secrets.EMAIL_USER}}> # <[email protected]>
# Optional plain body:
body: Hey Team, The latest code deployed. The server is up and running.
# Optional priority: 'high', 'normal' (default) or 'low'
priority: high