-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (73 loc) · 2.49 KB
/
image-build-push.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
name: Build & push image
on:
workflow_call:
inputs:
cr_domain:
description: The domain of the Container Registry (CR).
required: true
type: string
cr_repository:
description: Repository where the built image shall be pushed, e.g. 'slate-api'.
required: true
type: string
helm_release_namespace:
description: Kubernetes namespace corresponding to a Helm release, e.g. 'staging'.
required: true
type: string
repository:
description: The GitHub repository to clone, e.g. 'slateci/slate-client-server'.
required: false
default: ${{ github.repository }}
type: string
secrets:
cr_password:
description: The password for the robot account on the CR.
required: true
cr_username:
description: The username for the robot account on the CR.
required: true
jobs:
build-push:
name: Build/push image
runs-on: ubuntu-20.04
env:
BUILDKIT_CACHE_DIR: /tmp/buildkit-cache
steps:
- name: Download Shared Workflow Properties
uses: actions/download-artifact@v4
with:
name: shared-workflow-props
- name: Apply Shared Workflow Properties
working-directory: .
run: |-
source workflow.properties
echo "GIT_REF=${gitRef}" >> $GITHUB_ENV
echo "RELEASE_VERSION=${releaseVersion}" >> $GITHUB_ENV
- name: Check out repo
uses: actions/checkout@v4
with:
fetch-depth: 1
path: .
ref: ${{ env.GIT_REF }}
repository: ${{ inputs.repository }}
- name: Authenticate with CR
uses: docker/login-action@v3
with:
registry: ${{ inputs.cr_domain }}
username: "${{ secrets.cr_username }}"
password: "${{ secrets.cr_password }}"
- name: Enable Buildx Cache
uses: slateci/github-actions/.github/actions/buildkit-enable-cache@v17
with:
cache_dir: ${{ env.BUILDKIT_CACHE_DIR }}
- name: Configure Git
uses: slateci/github-actions/.github/actions/configure-git@v17
- name: Build/push image to CR
uses: docker/build-push-action@v5
with:
context: .
file: ./resources/docker/Dockerfile
build-args: versionoverride=${{ env.RELEASE_VERSION }}
target: release-stage
push: true
tags: "${{ inputs.cr_domain }}/slate/${{ inputs.cr_repository }}:${{ env.RELEASE_VERSION }}"