-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (87 loc) · 2.73 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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