π chore: pre-commit autoupdate #498
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: Test, Build, Deploy | |
on: | |
push: | |
branches: | |
- "**" | |
paths: | |
- "tubee/**" | |
- "app.py" | |
- "celery_worker.py" | |
- "pyproject.toml" | |
- "poetry.lock" | |
- ".github/workflows/test.yml" | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
test: | |
name: Test Coverage | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install poetry | |
run: pipx install poetry | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version-file: ".python-version" | |
cache: "poetry" | |
- name: Install Dependencies | |
run: | | |
poetry env use $(cat '.python-version') | |
poetry install --no-interaction --no-ansi | |
- name: Testing | |
run: poetry run flask test --coverage | |
- name: Report coverage | |
uses: codecov/codecov-action@v3 | |
license: | |
name: License Scan | |
runs-on: ubuntu-latest | |
if: ${{ github.event_path == 'pyproject.toml' || github.event_path == 'poetry.lock' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install poetry | |
run: pipx install poetry | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version-file: ".python-version" | |
cache: "poetry" | |
- name: Export requirements.txt | |
run: | | |
poetry export --dev -f requirements.txt --output requirements.txt | |
# FOSSA's API Key are meant to be exposed as to doc | |
- name: Scan License | |
uses: fossa-contrib/fossa-action@v1 | |
with: | |
fossa-api-key: 2d7865a44aa575d857521faaee1a57f8 | |
build: | |
name: Build and Push Image | |
runs-on: ubuntu-latest | |
needs: [test, license] | |
if: | | |
always() | |
&& (github.ref_name == 'main') | |
&& (github.event_name != 'pull_request') | |
&& (needs.test.result == 'success') | |
&& (needs.license.result == 'success' || needs.license.result == 'skipped') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ github.repository }} | |
ghcr.io/${{ github.repository }} | |
tags: | | |
type=edge | |
- name: Build and Push Image | |
uses: tomy0000000/actions/build-push-image@main | |
with: | |
docker_password: ${{ secrets.DOCKER_PASSWORD }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
deploy: | |
name: Deploy to Beta | |
runs-on: ubuntu-latest | |
environment: Beta | |
needs: build | |
if: ${{ always() && (needs.build.result == 'success') }} | |
steps: | |
- name: SSH and execute deployment | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
port: ${{ secrets.PORT }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
script_stop: true | |
script: | | |
cd tubee-beta | |
docker compose down | |
rm docker-compose.yml | |
wget "https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/docker-compose.yml" | |
docker compose pull --quiet | |
docker compose up --detach | |
docker network connect nginx_default tubee_beta_app |