Merge pull request #67 from wizelineacademy/I005-Testing #76
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: KnowX Backend Deploy | |
on: | |
push: | |
branches: | |
- DEV | |
jobs: | |
deploy: | |
name: "Deploy to AWS" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure SSH | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy-key.pem | |
chmod 600 ~/.ssh/deploy-key.pem | |
cat >> ~/.ssh/config <<END | |
Host my-vps | |
HostName $SSH_IP | |
User $SSH_USER | |
IdentityFile ~/.ssh/deploy-key.pem | |
StrictHostKeyChecking no | |
END | |
env: | |
SSH_USER: ${{ secrets.SSH_USER }} | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
SSH_IP: ${{ secrets.SSH_IP }} | |
- name: Make redeploy.sh executable | |
run: ssh my-vps 'cd ${{ secrets.PROJECT_ROOT }} && chmod +x redeploy.sh' | |
- name: Deploy API | |
run: ssh my-vps 'cd ${{ secrets.PROJECT_ROOT }} && ./redeploy.sh' | |
- name: Check container status | |
run: ssh my-vps 'cd ${{ secrets.PROJECT_ROOT }} && sudo docker compose ps' | |
- name: Send Deploy Failure Message | |
if: failure() | |
run: curl -s -X POST "${{ secrets.DISCORD_WEBHOOK }}" -d "content=🚨 Back Deploy Failed" | |
- name: Send Deploy Success Message | |
if: success() | |
run: | | |
curl -s -X POST "${{ secrets.DISCORD_WEBHOOK }}" -d "content=✅ Back Deploy Successful" | |
curl -s -X POST "${{ secrets.DISCORD_WEBHOOK }}" -d "content=🚀 API URL: ${{ secrets.API_FINAL_URL }}" |