trigger build #2
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 and build | |
# this workflow would be updated if we decide to have a more mature setup and | |
# have dev branch alongside branch protection rules for master and dev. | |
# For our purposes, since I'm the only one working on this, I'm just going to make it simple. | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- 'flask-app/pyproject.toml' | |
- 'flask-app/poetry.lock' | |
- 'flask-app/main.py' | |
- 'flask-app/tests/**' | |
- 'flask-app/src/**' | |
- 'flask-app/Dockerfile' | |
pull_request: | |
branches: | |
- master | |
paths: | |
- 'flask-app/pyproject.toml' | |
- 'flask-app/poetry.lock' | |
- 'flask-app/main.py' | |
- 'flask-app/tests/**' | |
- 'flask-app/src/**' | |
- 'flask-app/Dockerfile' | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Code Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Change directory | |
run: | | |
cd flask-app | |
ls -la | |
- name: Setup Poetry | |
run: pip install poetry==1.7.1 | |
- name: Install dependencies | |
run: | | |
cd flask-app | |
poetry install | |
- name: run tests | |
run: | | |
poetry run pytest tests/ | |
build_push: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Code Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Artifact Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: hkhairy | |
password: ${{ secrets.GH_PACKAGE_REGISTRY_KEY }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: flask-app/ | |
push: true | |
tags: 'ghcr.io/hkhairy/flask_app:${{ github.run_id }},ghcr.io/hkhairy/flask_app:latest' | |