Skip to content

docker

docker #6

name: ci
on:
push:
branches:
- "main"
paths-ignore:
- 'docs'
- '**.md'
pull_request:
branches:
- "main"
jobs:
test_and_lint:
name: Test and lint
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install requirements
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Black check
run: black --check .
- name: Run Mypy
run: mypy .
- name: Run Pytest
run: pytest
build_and_publish_image:
name: Build and publish image
needs: [test_and_lint]
if: github.event_name != 'pull_request'
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: 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 }}