refactored code #135
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 EC2 | |
on: | |
push: | |
branches: [master] | |
workflow_dispatch: | |
jobs: | |
tests: | |
name: Run tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Install Requirements | |
run: | | |
pip install --upgrade pip | |
pip install -r dev-requirements.txt | |
pip install -r requirements.txt | |
- name: Run Flake8 | |
run: flake8 --max-line-length 119 ./src | |
- name: Prepare TestBed | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y libopus-dev | |
- name: Test Run Boi | |
run: | | |
python src/main.py & | |
sleep 20 | |
kill "$!" | |
env: | |
BOT_TOKEN: ${{ secrets.TEST_BOI_DC_TOKEN }} | |
SERVER_IP: ${{ secrets.SERVER_IP }} | |
SERVER_PORT: ${{ secrets.SERVER_PORT }} | |
SERVER_ENDPOINT: ${{ secrets.SERVER_ENDPOINT }} | |
WAVELINK_URL: ${{ secrets.WAVELINK_URL }} | |
WAVELINK_PORT: ${{ secrets.WAVELINK_PORT }} | |
WAVELINK_PASSWORD: ${{ secrets.WAVELINK_PASSWORD }} | |
docker_build: | |
name: Build and push docker container | |
needs: tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: ghcr.io/wkk-offcial/boi_redemption_arc:latest,ghcr.io/wkk-offcial/boi_redemption_arc:${{ github.sha }} | |
trigger_deploy: | |
name: Trigger deployment pipeline | |
runs-on: ubuntu-latest | |
needs: docker_build | |
steps: | |
- name: Trigger deployment pipeline | |
run: | | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.DEPLOY_API_TOKEN }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/WKK-Offcial/bot_deployment/actions/workflows/deploy.yml/dispatches \ | |
-d '{"ref":"master"}' |