-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathpublish-release-to-dockerhub-workflow.yaml
More file actions
171 lines (152 loc) · 5.17 KB
/
publish-release-to-dockerhub-workflow.yaml
File metadata and controls
171 lines (152 loc) · 5.17 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Publish Docker images
on:
release:
types: [published]
workflow_dispatch:
inputs:
target_tag:
description: "The ref run this workflow against (e.g., v1.0.0)"
required: true
type: string
jobs:
astarte_appengine_api:
uses: ./.github/workflows/astarte-apps-build-workflow.yaml
with:
app: "astarte_appengine_api"
secrets: inherit
astarte_data_updater_plant:
uses: ./.github/workflows/astarte-apps-build-workflow.yaml
with:
app: "astarte_data_updater_plant"
secrets: inherit
astarte_housekeeping:
uses: ./.github/workflows/astarte-apps-build-workflow.yaml
with:
app: "astarte_housekeeping"
secrets: inherit
astarte_pairing:
uses: ./.github/workflows/astarte-apps-build-workflow.yaml
with:
app: "astarte_pairing"
secrets: inherit
astarte_realm_management:
uses: ./.github/workflows/astarte-apps-build-workflow.yaml
with:
app: "astarte_realm_management"
secrets: inherit
astarte_trigger_engine:
uses: ./.github/workflows/astarte-apps-build-workflow.yaml
with:
app: "astarte_trigger_engine"
secrets: inherit
e2e_tests:
uses: ./.github/workflows/astarte-end-to-end-test-workflow.yaml
build_release:
name: Push Docker images to Docker Hub
runs-on: ${{ matrix.platform.os }}
permissions:
packages: write
contents: read
attestations: write
id-token: write
strategy:
fail-fast: true
matrix:
platform:
- os: ubuntu-22.04
platform: linux/amd64
platform-pair: linux-amd64
- os: ubuntu-22.04-arm
platform: linux/arm64
platform-pair: linux-arm64
app:
- astarte_appengine_api
- astarte_data_updater_plant
- astarte_housekeeping
- astarte_pairing
- astarte_realm_management
- astarte_trigger_engine
needs:
- astarte_appengine_api
- astarte_data_updater_plant
- astarte_housekeeping
- astarte_pairing
- astarte_realm_management
- astarte_trigger_engine
- e2e_tests
steps:
- name: Check out the repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ inputs.target_tag || github.ref }}
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Build Docker image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
id: build
with:
context: .
build-args: SERVICE=${{ matrix.app }}
push: true
tags: astarte/${{ matrix.app }}
platforms: ${{ matrix.platform.platform }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests/
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: ${{ matrix.app }}-digests-${{ matrix.platform.platform-pair }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
merge_images:
name: Publish release
runs-on: ubuntu-24.04
needs:
- build_release
strategy:
fail-fast: true
matrix:
app:
- astarte_appengine_api
- astarte_data_updater_plant
- astarte_housekeeping
- astarte_pairing
- astarte_realm_management
- astarte_trigger_engine
steps:
- name: Download digests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
path: ${{ runner.temp }}/digests
pattern: ${{ matrix.app }}-digests-*
merge-multiple: true
- name: Login to Docker Hub
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: |
astarte/${{ matrix.app }}
tags: |
type=semver,pattern={{version}},value=${{ inputs.target_tag || github.event.release.tag_name }}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests/
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'astarte/${{ matrix.app }}@sha256:%s ' *)