Skip to content

EveryGSM stage CD workflow #101

EveryGSM stage CD workflow

EveryGSM stage CD workflow #101

name: EveryGSM stage CD workflow
on:
push:
branches:
- 'develop'
workflow_dispatch:
jobs:
CD:
runs-on: ubuntu-latest
environment: stage
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@v1
env:
APPLICATION_YML: ${{ secrets.APPLICATION_YML }}
DB_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
envs: APPLICATION_YML,DB_ROOT_PASSWORD,DB_USERNAME,DB_PASSWORD
script: |
git config --global --add safe.directory /opt/everygsm
git -C /opt/everygsm config pull.rebase false
git -C /opt/everygsm pull origin develop
echo "$APPLICATION_YML" > /opt/everygsm/src/main/resources/application-stage.yml
printf 'DB_ROOT_PASSWORD=%s\nDB_USERNAME=%s\nDB_PASSWORD=%s\n' "$DB_ROOT_PASSWORD" "$DB_USERNAME" "$DB_PASSWORD" > /opt/everygsm/.env
docker compose -f /opt/everygsm/deploy/docker/compose.stage.yaml up --build -d
docker image prune -f
- name: CD Success Notification
uses: sarisia/actions-status-discord@v1
if: success()
with:
webhook: ${{ secrets.DISCORD_INFORMATION_ALERT_CHANNEL_WEBHOOK }}
color: 0x4CAF50
- name: CD Failure Notification
uses: sarisia/actions-status-discord@v1
if: failure()
with:
webhook: ${{ secrets.DISCORD_INFORMATION_ALERT_CHANNEL_WEBHOOK }}
color: 0xFF4C4C
- name: CD Cancelled Notification
uses: sarisia/actions-status-discord@v1
if: cancelled()
with:
webhook: ${{ secrets.DISCORD_INFORMATION_ALERT_CHANNEL_WEBHOOK }}
color: 0xFFC107