ci: update ci and add format check and tests #28
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: ci | |
on: | |
push: | |
branches: | |
- "main" | |
paths-ignore: | |
- 'docs' | |
- '**.md' | |
jobs: | |
build_and_publish_image: | |
permissions: | |
contents: read | |
packages: write | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Run tests | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
black --check . | |
pytest | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get commit short | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
ghcr.io/tbmc/sporteasy-calendar-connector:latest | |
ghcr.io/tbmc/sporteasy-calendar-connector:${{ steps.vars.outputs.sha_short }} | |
tbmc/sporteasy-calendar-connector:latest | |
tbmc/sporteasy-calendar-connector:${{ steps.vars.outputs.sha_short }} |