-
Notifications
You must be signed in to change notification settings - Fork 41
175 lines (156 loc) · 5.41 KB
/
docker-build-deeploy.yml
File metadata and controls
175 lines (156 loc) · 5.41 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
172
173
174
175
# SPDX-FileCopyrightText: 2025 ETH Zurich and University of Bologna
#
# SPDX-License-Identifier: Apache-2.0
---
name: Docker • Build Deeploy Container
"on":
workflow_dispatch:
inputs:
docker_image_toolchain:
description: "Deeploy Toolchain Image to use"
required: false
default: "ghcr.io/pulp-platform/deeploy-toolchain:latest"
jobs:
prepare:
name: Fetch branch name or tag
runs-on: ubuntu-latest
outputs:
docker_tag: ${{ steps.generate_tag.outputs.docker_tag }}
docker_release_tag: ${{ steps.detect_release_tag.outputs.release_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up environment variables
run: |
echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "TAG_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "IS_TAG=${GITHUB_REF_TYPE}" >> $GITHUB_ENV
- name: Set Docker tag
id: generate_tag
run: |
if [[ "${{ env.IS_TAG }}" == "tag" ]]; then
echo "docker_tag=${{ env.TAG_NAME }}" >> $GITHUB_OUTPUT
else
echo "docker_tag=${{ env.BRANCH_NAME }}" >> $GITHUB_OUTPUT
fi
- name: Detect release tag on HEAD
id: detect_release_tag
run: |
TAG_ON_HEAD=$(git tag --points-at HEAD | head -n 1 || true)
if [[ -n "$TAG_ON_HEAD" && "$IS_TAG" != "tag" ]]; then
echo "release_tag=$TAG_ON_HEAD" >> $GITHUB_OUTPUT
else
echo "release_tag=" >> $GITHUB_OUTPUT
fi
build-deeploy:
name: Build Deploy Image
needs: [prepare]
runs-on: ${{ matrix.runner }}
outputs:
digest-amd64: ${{ steps.digest.outputs.digest-amd64 }}
digest-arm64: ${{ steps.digest.outputs.digest-arm64 }}
strategy:
fail-fast: false
matrix:
platform: [amd64, arm64]
include:
- platform: amd64
runner: ubuntu-latest
- platform: arm64
runner: ubuntu-22.04-arm
steps:
- uses: actions/checkout@v4
- name: Free up disk space
uses: jlumbroso/free-disk-space@v1.3.1
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
- uses: docker/setup-buildx-action@v3
- name: GHCR Log-in
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Cache for Docker
id: cache
uses: actions/cache@v4
with:
path: var-ccache
key: ${{ runner.os }}-${{ matrix.platform }}-build-cache-deeploy
- name: Inject build-cache
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-map: |
{
"var-ccache": "/ccache"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: Lower Case Repository Name
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
env:
OWNER: "${{ github.repository_owner }}"
- name: Build and push final Deeploy image
id: build
uses: docker/build-push-action@v6
with:
platforms: linux/${{ matrix.platform }}
context: .
cache-from: type=gha
cache-to: type=gha,mode=min
file: Container/Dockerfile.deeploy
push: true
build-args: |
BASE_IMAGE=${{ github.event.inputs.docker_image_toolchain }}
outputs: type=image,name=ghcr.io/${{ env.OWNER_LC }}/deeploy,annotation-index=true,name-canonical=true,push=true
- name: Extract image digest
id: digest
run: echo "digest-${{ matrix.platform }}=${{ steps.build.outputs.digest }}" >> $GITHUB_OUTPUT
merge-deeploy-images:
name: Merge Deeploy Images
runs-on: ubuntu-latest
needs: [prepare, build-deeploy]
steps:
- name: GHCR Log-in
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Lower Case Repository Name
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
env:
OWNER: "${{ github.repository_owner }}"
- name: Prepare manifest tags
id: manifest_tags
run: |
OWNER_LC_VALUE=${OWNER,,}
{
echo "tags<<EOF"
echo "ghcr.io/${OWNER_LC_VALUE}/deeploy:latest,"
if [[ -n "${RELEASE_TAG}" ]]; then
echo "ghcr.io/${OWNER_LC_VALUE}/deeploy:${DOCKER_TAG},"
echo "ghcr.io/${OWNER_LC_VALUE}/deeploy:${RELEASE_TAG}"
else
echo "ghcr.io/${OWNER_LC_VALUE}/deeploy:${DOCKER_TAG}"
fi
echo "EOF"
} >> $GITHUB_OUTPUT
env:
OWNER: ${{ github.repository_owner }}
DOCKER_TAG: ${{ needs.prepare.outputs.docker_tag }}
RELEASE_TAG: ${{ needs.prepare.outputs.docker_release_tag }}
- name: Merge Deeploy Images
uses: Noelware/docker-manifest-action@v1
with:
inputs: |
ghcr.io/${{ env.OWNER_LC }}/deeploy@${{ needs.build-deeploy.outputs.digest-amd64 }},
ghcr.io/${{ env.OWNER_LC }}/deeploy@${{ needs.build-deeploy.outputs.digest-arm64 }}
tags: ${{ steps.manifest_tags.outputs.tags }}
push: true