Merge branch 'main' of https://github.com/RaZoom-Team/meeting-2107 #39
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 | |
on: | |
push: | |
branches: | |
- main | |
env: | |
SERVER_USER: ${{ vars.SERVER_USER }} | |
SERVER_HOST: ${{ vars.SERVER_HOST }} | |
SERVER_DIR: ${{ vars.SERVER_DIR }} | |
jobs: | |
build: | |
runs-on: self-hosted | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build on github | |
run: docker compose build | |
build-and-run: | |
runs-on: self-hosted | |
needs: build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up SSH | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Generate auth hosts | |
run: ssh-keyscan -H ${{ vars.SERVER_HOST }} >> ~/.ssh/known_hosts | |
- name: Check connection | |
run: ssh ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} whoami | |
- name: Sync with server | |
run: rsync -avz --exclude='.env' ./ ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }}:${{ vars.SERVER_DIR }} | |
- name: Build | |
run: | | |
ssh $SERVER_USER@$SERVER_HOST << EOF | |
cd $SERVER_DIR | |
docker compose build | |
EOF | |
- name: Run | |
run: | | |
ssh $SERVER_USER@$SERVER_HOST << EOF | |
cd $SERVER_DIR | |
docker compose up -d | |
EOF | |
# - name: Download report req | |
# run: pip install -r ./utils/requirements.txt | |
- name: Send report | |
env: | |
TG_TOKEN: ${{ secrets.TG_TOKEN }} | |
TG_CHAT_ID: ${{ vars.TG_CHAT_ID }} | |
BUILD_NAME: ${{ github.event.head_commit.message }} | |
run: python3 ./utils/send_result.py success | |
fail-report: | |
runs-on: self-hosted | |
if: failure() | |
needs: [build, build-and-run] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# - name: Download report req | |
# run: pip install -r ./utils/requirements.txt | |
- name: Send report | |
env: | |
TG_TOKEN: ${{ secrets.TG_TOKEN }} | |
TG_CHAT_ID: ${{ vars.TG_CHAT_ID }} | |
BUILD_NAME: ${{ github.event.head_commit.message }} | |
run: python3 ./utils/send_result.py fail |