-
Notifications
You must be signed in to change notification settings - Fork 23
99 lines (80 loc) · 2.47 KB
/
cd.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
98
99
name: cd
on:
push:
branches: [main]
schedule:
- cron: "43 1 * * SUN" # every Sunday at 1:43 AM UTC
workflow_dispatch:
env:
IMAGE_NAME: network-tools
jobs:
publish:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
permissions:
packages: write
contents: read
steps:
- name: Check out repository
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 GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Lint Dockerfile
run: make lint
- name: Extract metadata for images
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
# manually handle the 'latest' tag
flavor: |
latest=false
tags: |
type=raw,value=latest
labels: |
org.opencontainers.image.licenses=MIT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push images
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
prune:
needs: publish
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
permissions:
packages: write
contents: read
env:
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
steps:
- name: Checkout Git repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --requirement .github/scripts/ghcr/prune/requirements.txt
- name: Prune all untagged images
run: python .github/scripts/ghcr/prune/prune.py --container ${{ env.IMAGE_NAME }} --prune-all-untagged --verbose