-
Notifications
You must be signed in to change notification settings - Fork 224
100 lines (86 loc) · 3.02 KB
/
docker-image.yml
File metadata and controls
100 lines (86 loc) · 3.02 KB
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
100
name: Publish Docker image
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Docker image version"
type: string
required: true
env:
DOCKER_IMAGE_NAME: "grimoirelab/grimoirelab"
jobs:
package-ready:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.12
- name: Wait for GrimoireLab package ready in PyPI
run: |
package="grimoirelab"
ref_name="${{github.ref_name}}"
input_version="${{inputs.version}}"
version="${input_version:-$ref_name}"
pip install --upgrade pip
retries=20
delay=30
for i in $(seq $retries);
do
pip install --dry-run --no-deps $package==$version && exit 0
echo "Attempt $i: Package $package==$version not found in PyPI. Retrying in $delay seconds..."
sleep $delay
done
echo "Package $package==$version not found in PyPI after waiting. Exiting."
exit 1 # Fail the job
build-image:
runs-on: ubuntu-latest
needs: [package-ready]
environment: docker-release
permissions:
contents: read
id-token: write # needed for signing the images with GitHub OIDC Token
steps:
- name: Install Cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Docker metadata
id: meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
images: |
${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=${{ inputs.version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
with:
platforms: linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to DockerHub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: build-and-push
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
platforms: linux/amd64,linux/arm64
context: "{{defaultContext}}:docker"
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
GRIMOIRELAB_RELEASE=${{ inputs.version }}
- name: Sign the images with GitHub OIDC Token
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}