-
Notifications
You must be signed in to change notification settings - Fork 52
75 lines (68 loc) · 2.58 KB
/
image.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
name: Create and publish a Docker image
on:
push:
branches: ['main']
paths:
- 'ci/dockerfiles/**'
- '.github/workflows/image.yml'
- '.tool-versions'
pull_request:
paths:
- 'ci/dockerfiles/**'
- '.github/workflows/image.yml'
- '.tool-versions'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
strategy:
matrix:
image_suffix: ["tools"]
name: Build and Push app-autoscaler-release-${{ matrix.image_suffix }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # 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@369eb591f429131d6889c46b94e711f089e6ca96 # v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.image_suffix }}
- name: Get ginkgo version from autoscaler-release
id: ginkgo
run: |
version=$(grep "ginkgo " .tool-versions| cut -f 2 -d " ")
echo "GINKGO version from .tool-versions: \'${version}\'"
echo "version=${version}" >> "$GITHUB_OUTPUT"
- id: get-golang-version
shell: bash
run: |
version=$(grep "golang " .tool-versions| cut -f 2 -d " ")
echo "Go version from .tool-versions: \'${version}\'"
echo "version=${version}" >> "$GITHUB_OUTPUT"
- name: Build and push
id: build-and-push
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6
with:
context: ci/dockerfiles/autoscaler-${{ matrix.image_suffix }}
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.image_suffix }}:main
build-args: |
GINKGO_VERSION=v${{ steps.ginkgo.outputs.version }}
GO_VERSION=${{ steps.get-golang-version.outputs.version }}