-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (82 loc) · 2.77 KB
/
docker-publish.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
name: Docker publish
on:
schedule:
# @weekly
- cron: "0 0 * * SUN"
push:
branches: ["main"]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
strategy:
matrix:
distro: [ubuntu]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/${{ matrix.distro }}
steps:
# Docker build using Git context, no need to use checkout action
# - name: Checkout repository
# uses: actions/checkout@v4
# Add support for more platforms with QEMU (optional)
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# By default, builder driver is `docker`, which currently not supported
# building multi-platform images or exporting cache.
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
uses: docker/metadata-action@v5
id: meta
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=22.04
labels: |
org.opencontainers.image.title=Ubuntu 22.04 Actions runner images
org.opencontainers.image.description=Ubuntu 22.04 docker image used of (GitHub) Actions runner
annotations: |
org.opencontainers.image.title=Ubuntu 22.04 Actions runner images
org.opencontainers.image.description=Ubuntu 22.04 docker image used of (GitHub) Actions runner
- name: Docker builder info
run: |
set -x
docker buildx version
docker buildx ls
docker buildx inspect
- name: Build and push Docker image
uses: docker/build-push-action@v6
id: publish
with:
pull: true
push: true
sbom: true
provenance: true
context: "{{defaultContext}}:${{ matrix.distro }}"
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: |
linux/amd64
linux/arm64
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
id: attest
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.publish.outputs.digest }}
push-to-registry: true