-
-
Notifications
You must be signed in to change notification settings - Fork 5
92 lines (82 loc) · 3.27 KB
/
build-verify.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: build-verify-package
on:
push:
paths-ignore:
#- '.github/**'
- '.gitignore'
- 'LICENSE'
- '*.md'
pull_request:
paths-ignore:
- '.github/**'
- '.gitignore'
- 'LICENSE'
- '*.md'
permissions:
contents: read
id-token: write # needed for signing the images with GitHub OIDC Token
jobs:
build-verify-package:
runs-on: ubuntu-latest
environment: Build
steps:
- name: Get current date
id: date
#run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%S')"
run: echo "date=$(date +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Checkout Code
uses: actions/checkout@v4
- name: Set environment for branch
run: |
set -x
if [[ $GITHUB_REF == 'refs/heads/master' ]]; then
echo "IMAGE_TAG=nightly" >> "$GITHUB_ENV"
echo "PACKAGE_IMAGE=true" >> "$GITHUB_ENV"
elif [[ $GITHUB_REF == "refs/tags/$GITHUB_REF_NAME" ]]; then
echo "IMAGE_TAG=$GITHUB_REF_NAME" >> "$GITHUB_ENV"
echo "PACKAGE_IMAGE=true" >> "$GITHUB_ENV"
else
echo "PACKAGE_IMAGE=false" >> "$GITHUB_ENV"
fi
- name: Install Cosign
uses: sigstore/[email protected]
- name: Set up QEMU
if: github.repository_owner == 'microcks' && env.PACKAGE_IMAGE == 'true'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: github.repository_owner == 'microcks' && env.PACKAGE_IMAGE == 'true'
uses: docker/setup-buildx-action@v3
- name: Login to Quay.io and Docker Hub registries and setup multi-arch builder
if: github.repository_owner == 'microcks' && env.PACKAGE_IMAGE == 'true'
run: |
echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin docker.io
BUILDER=buildx-multi-arch
docker buildx inspect $BUILDER || docker buildx create --name=$BUILDER --driver=docker-container --driver-opt=network=host
- name: Build and push container image
id: build-and-push
uses: docker/[email protected]
if: github.repository_owner == 'microcks' && env.PACKAGE_IMAGE == 'true'
with:
context: .
sbom: true
push: true
provenance: mode=max
platforms: linux/amd64,linux/arm64
builder: buildx-multi-arch
file: Dockerfile
labels: |
org.opencontainers.image.revision=${GITHUB_SHA}
org.opencontainers.image.created=${{ steps.date.outputs.date }}
tags: quay.io/microcks/microcks-hub:${{env.IMAGE_TAG}},docker.io/microcks/microcks-hub:${{env.IMAGE_TAG}}
- name: Sign the image with GitHub OIDC Token
env:
DIGEST: ${{ steps.build-and-push.outputs.digest }}
TAGS: quay.io/microcks/microcks-hub:${{env.IMAGE_TAG}} docker.io/microcks/microcks-hub:${{env.IMAGE_TAG}}
COSIGN_EXPERIMENTAL: "true"
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}