-
Notifications
You must be signed in to change notification settings - Fork 12
81 lines (79 loc) · 2.87 KB
/
Copy pathbuild-image.yaml
File metadata and controls
81 lines (79 loc) · 2.87 KB
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
name: Build and Publish Images
on:
push:
branches: ["*"]
tags:
- "v[0-9]+.[0-9]+.[0-9]+-?**"
env:
IMG_REGISTRY_HOST: quay.io
IMG_REGISTRY_ORG: kuadrant
IMG_REGISTRY_REPO: developer-portal-controller
jobs:
build:
name: Build and Push image
runs-on: ubuntu-latest
outputs:
image: ${{ steps.meta.outputs.tags }}
steps:
- name: Check out code
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to container registry
uses: docker/login-action@v2
with:
username: ${{ secrets.IMG_REGISTRY_USERNAME }}
password: ${{ secrets.IMG_REGISTRY_TOKEN }}
registry: ${{ env.IMG_REGISTRY_HOST }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.IMG_REGISTRY_REPO }}
flavor: |
latest=false
tags: |
# branch event
type=ref,enable=true,priority=600,prefix=,suffix=,event=branch
# git sha
type=raw,value=${{ github.sha }},enable={{is_default_branch}}
# will be used on a push tag event and requires a valid semver Git tag
type=semver,pattern={{raw}}
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- name: Read release string version
id: release
run: |
version=`make read-release-version`
echo version=$version >> $GITHUB_OUTPUT
- name: Read quay image expiry
id: quay-expiry
run: |
if [[ "${{ github.ref_name }}" == "main" || "${{ github.ref_type }}" == "tag" && "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
echo "expiry=never" >> $GITHUB_OUTPUT
echo "Setting expiry to 'never' for ref ${{ github.ref_name }}"
else
expiry=`make read-quay-image-expiry`
echo expiry=$expiry >> $GITHUB_OUTPUT
echo "Reading expiry from Makefile, set to $expiry for ref ${{ github.ref_name }}"
fi
- name: Build and Push Image
if: github.repository_owner == 'kuadrant'
id: build-image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le
push: true
provenance: false
tags: ${{ steps.meta.outputs.tags }}
build-args: |
GIT_SHA=${{ github.sha }}
DIRTY=false
VERSION=${{ steps.release.outputs.version }}
QUAY_IMAGE_EXPIRY=${{ steps.quay-expiry.outputs.expiry }}
- name: Print Image URL
run: |
echo "Image(s) pushed:"
echo "${{ steps.meta.outputs.tags }}"