Reduce PDM layer #68
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: Build traffcap | |
on: | |
push: | |
branches: ["master"] | |
tags: ["*"] | |
pull_request: | |
branches: ["master"] | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.9" | |
- name: Install dependencies | |
run: | | |
curl -sSL https://pdm.fming.dev/install-pdm.py | python3 - | |
pdm install | |
- name: Lint with Ruff | |
run: pdm run lint | |
- name: Test with pytest | |
run: pdm run test | |
build_docker_image: | |
name: Build & Push Docker image | |
needs: build | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_NAME: ${{ github.repository }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Log in to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta_ghcr | |
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | |
with: | |
images: ghcr.io/${{ env.IMAGE_NAME }} | |
tags: | | |
# minimal (short sha) | |
type=sha | |
# set latest tag for master branch | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta_docker | |
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | |
with: | |
images: | | |
centurix/traffcap | |
tags: | | |
# minimal (short sha) | |
type=sha | |
# set latest tag for master branch | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
id: push | |
with: | |
push: true | |
tags: | | |
${{ steps.meta_ghcr.outputs.tags }} | |
${{ steps.meta_docker.outputs.tags }} | |
labels: | | |
${{ steps.meta_ghcr.outputs.labels }} | |
${{ steps.meta_docker.outputs.labels }} | |
- name: Generate ghcr artifact attestation | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-name: ghcr.io/${{ env.IMAGE_NAME}} | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true |