-
Notifications
You must be signed in to change notification settings - Fork 14
82 lines (75 loc) · 2.61 KB
/
buildReleaseContainers.yaml
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
name: Build Release Specific Containers
on:
workflow_call:
inputs:
container-tag:
type: string
required: true
workflow_dispatch:
inputs:
container-tag:
type: string
required: true
jobs:
list-containers:
uses: ./.github/workflows/listContainers.yaml
build:
name: Build containers
needs: list-containers
runs-on: ubuntu-latest
strategy:
matrix:
container-to-build: ${{fromJson(needs.list-containers.outputs.all-containers)}}
permissions:
contents: "read"
id-token: "write"
packages: "write"
steps:
- name: Check Out Changes
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.container-tag }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
ref: ${{ inputs.container-tag }}
images: ghcr.io/${{ github.repository }}/${{matrix.container-to-build}}
# this sets the version for tags and labels for each of the containers to be
# be the same as the version/tag where the code was pulled from
tags: |
type=semver,pattern={{raw}},value=${{ inputs.container-tag }}
type=ref,event=branch
type=ref,event=tag,pattern={{raw}},value=${{ inputs.container-tag }}
labels: |
org.opencontainers.image.version=${{ inputs.container-tag }}
- name: Build and push
uses: docker/build-push-action@v3
if: ${{ !contains(fromJSON('["ecr-viewer"]'), matrix.container-to-build) }}
with:
context: ./containers/${{matrix.container-to-build}}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push with shared-resources
uses: docker/build-push-action@v3
if: ${{ contains(fromJSON('["ecr-viewer"]'), matrix.container-to-build) }}
with:
context: .
file: ./containers/${{ matrix.container-to-build }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max