ci: update actions #212
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: aristaeus | |
on: | |
push: | |
paths: | |
- "aristaeus/**" | |
- ".github/workflows/aristaeus.yaml" | |
defaults: | |
run: | |
shell: bash | |
working-directory: aristaeus | |
jobs: | |
validation: | |
name: lint & pytest | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:latest | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_DB: dbtest | |
POSTGRES_USER: dbtest | |
POSTGRES_PASSWORD: dbtest | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
env: | |
AKB_DATABASE_HOST: localhost | |
AKB_DATABASE_PORT: 5432 | |
AKB_DATABASE_USER: dbtest | |
AKB_DATABASE_PASSWORD: dbtest | |
AKB_DATABASE_DBNAME: dbtest | |
steps: | |
- name: install python3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: install poetry | |
run: pip install poetry | |
- name: setup env | |
run: poetry install | |
- name: black | |
run: poetry run black . --check | |
- name: pytest | |
run: poetry run coverage run -m pytest tests/unit | |
- name: coverage report | |
run: poetry run coverage report | |
- name: pytest | |
run: poetry run pytest tests/integration | |
release: | |
name: release new version | |
runs-on: ubuntu-latest | |
needs: validation | |
if: github.ref == 'refs/heads/master' | |
env: | |
GITHUB_TOKEN: ${{ secrets.CI_USER_TOKEN }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: 'master' | |
- name: install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: install dependencies | |
run: sudo npm install -g semantic-release @semantic-release/git @semantic-release/exec | |
- name: pull master | |
run: git pull | |
- name: run semantic release | |
run: semantic-release | |
build: | |
name: build docker image | |
runs-on: ubuntu-latest | |
needs: release | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: 'master' | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: install poetry | |
run: pip install poetry | |
- name: git latest tag | |
run: | | |
git fetch --tags --prune --unshallow | |
tag=$(git describe --tags --abbrev=0 --match 'aristaeus-*') | |
version=$(echo $tag | cut -d'-' -f2 | cut -d'v' -f2) | |
echo "image_version=${version}" >> $GITHUB_ENV | |
- name: Export requirements | |
run: poetry export -o requirements.txt | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: aristaeus | |
platforms: linux/amd64,linux/arm/v7,linux/arm64 | |
push: true | |
tags: | | |
yomain/aristaeus:${{ env.image_version }} | |
yomain/aristaeus:latest |