-
Notifications
You must be signed in to change notification settings - Fork 51
112 lines (101 loc) · 3.26 KB
/
_build-img-nucliadb.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# This is a reusable workflow.
name: Build a container image
on:
workflow_call:
inputs:
image-name:
description: "Image tags."
type: string
required: false
default: ""
context:
description: "Docker build context (default: .)"
type: string
required: false
default: "."
file:
description: "Path to dockerfile."
type: string
required: false
default: ""
platforms:
description: "Platforms to build for (default: linux/amd64)"
type: string
required: false
default: "linux/amd64"
cache-gha-mode:
description: "Parameter `mode` for `cache-from type=gha` (default: max)"
type: string
required: false
default: "max"
skip:
description: "If `true`, skip everything (default: `false`)."
type: boolean
required: false
default: false
outputs:
imageid:
value: ${{ jobs.build-img.outputs.imageid }}
digest:
value: ${{ jobs.build-img.outputs.digest }}
metadata:
value: ${{ jobs.build-img.outputs.metadata }}
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
env:
GCP_WORKLOAD_IDENTITY_PROVIDER: "projects/224545243904/locations/global/workloadIdentityPools/gh-nuclia/providers/gh-nuclia-provider"
GCP_SERVICE_ACCOUNT: "[email protected]"
jobs:
build-img:
name: Build image
runs-on: ubuntu-24.04
outputs:
imageid: ${{ steps.build-image.outputs.imageid }}
digest: ${{ steps.build-image.outputs.digest }}
metadata: ${{ steps.build-image.outputs.metadata }}
steps:
- name: Skip everything, if needed.
run: |
if [[ "${{ inputs.skip }}" == "true" ]]; then
echo "Doing nothing because skip=true."
exit 0
fi
- name: Checkout repository
uses: actions/checkout@v4
- name: default values for arguments
id: default
run: |
FILE="${{ inputs.file }}"
if [[ -z "$FILE" ]] ; then
FILE="${{ inputs.context }}/Dockerfile"
fi
echo "file=${FILE}" >> "${GITHUB_OUTPUT}"
echo "file: ${FILE}"
# required for using buildx on self-hosted runners
- name: Set up Docker Context for Buildx
run: |
docker context create builders
# required for using gha cache backend
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
endpoint: builders
- name: Build image
id: build-image
uses: docker/build-push-action@v5
with:
context: ${{ inputs.context }}
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=${{ inputs.cache-gha-mode }}
file: ${{ steps.default.outputs.file }}
platforms: ${{ inputs.platforms }}
- name: Push image
id: push-image
uses: ./.github/actions/push-img-nucliadb
with:
imageid: ${{ steps.build-image.outputs.imageid }}
image-name: ${{ inputs.image-name }}
aws-ecr-role: ${{ secrets.AWS_ECR_ROLE }}