-
Notifications
You must be signed in to change notification settings - Fork 21
100 lines (91 loc) · 3.1 KB
/
stackhpc-build-kayobe-image.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
---
# This reusable workflow builds a Kayobe container image using the Dockerfile
# in kayobe-automation, then pushes it to a registry.
name: Build kayobe image
on:
push:
branches:
# NOTE(upgrade): Reference only the current release branch here.
- stackhpc/2023.1
workflow_call:
inputs:
http_proxy:
type: string
required: false
https_proxy:
type: string
required: false
no_proxy:
type: string
required: false
base_image:
type: string
required: false
default: "rockylinux:9"
if:
description: Whether to run the workflow (workaround for required status checks issue)
type: boolean
default: true
outputs:
kayobe_image:
description: Reference of Kayobe image that was built
value: ${{ jobs.build-kayobe-image.outputs.kayobe_image }}
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-kayobe-image:
name: Build kayobe image
if: inputs.if || github.repository == 'stackhpc/stackhpc-kayobe-config' && github.event_name == 'push'
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
outputs:
kayobe_image: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout kayobe config
uses: actions/checkout@v4
with:
submodules: true
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:master
env.http_proxy=${{ env.http_proxy }}
env.https_proxy=${{ env.https_proxy }}
# Doesn't like commas: invalid value "127.0.0.1", expecting k=v
# env.no_proxy='${{ env.no_proxy }}'
env:
http_proxy: ${{ inputs.http_proxy }}
https_proxy: ${{ inputs.https_proxy }}
no_proxy: ${{ inputs.no_proxy }}
# Setting KAYOBE_USER_UID and KAYOBE_USER_GID to 1001 to match docker's defaults
# so that docker can run as a privileged user within the Kayobe image.
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./.automation/docker/kayobe/Dockerfile
context: .
build-args: |
http_proxy=${{ inputs.http_proxy }}
https_proxy=${{ inputs.https_proxy }}
BASE_IMAGE=${{ inputs.base_image || 'rockylinux:9' }}
KAYOBE_USER_UID=1001
KAYOBE_USER_GID=1001
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}