-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (73 loc) · 2.43 KB
/
build_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
76
77
78
79
80
81
82
83
name: Build and Push Image
on:
push:
branches:
- 'main'
- 'refs/tags/releases/v*'
tags:
- 'releases/v**'
workflow_dispatch:
env:
IMAGE_NAME: yacfg_artemis
IMAGE_REGISTRY: quay.io
IMAGE_NAMESPACE: rhmessagingqe
ARCHS: amd64,arm64
jobs:
build:
name: Build and push image
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Build Main Branch Image
if: github.ref == 'refs/heads/main'
id: build-main-branch-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: |
latest
main
${{ github.sha }}
archs: ${{ env.ARCHS }}
containerfiles: |
./Dockerfile
- name: Get tag name
if: startsWith(github.ref, 'refs/tags/releases/v')
id: tag
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/releases/v}" >> $GITHUB_OUTPUT
- name: Build Release Image
if: startsWith(github.ref, 'refs/tags/releases/v')
id: build-release-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: |
${{ github.sha }}
${{ steps.tag.outputs.TAG_NAME }}
archs: ${{ env.ARCHS }}
containerfiles: |
./Dockerfile
- name: Push Main Image to quay.io
if: github.ref == 'refs/heads/main'
id: push-main-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-main-branch-image.outputs.image }}
tags: ${{ steps.build-main-branch-image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Push Release Image to quay.io
if: startsWith(github.ref, 'refs/tags/releases/v')
id: push-release-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-release-image.outputs.image }}
tags: ${{ steps.build-release-image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Print image URL
run: echo "Image pushed to ${{ steps.push-main-to-quay.outputs.registry-paths }} ${{ steps.push-release-to-quay.outputs.registry-paths }}"