-
Notifications
You must be signed in to change notification settings - Fork 23
65 lines (57 loc) · 1.99 KB
/
build_push_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
name: Build and push container image
on:
workflow_dispatch:
inputs:
release_tags:
required: false
default: "next"
release:
types: [released]
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set environment
run: |
if [ "${{ github.event_name }}" == "release" ]; then
# https://github.com/orgs/community/discussions/64736
latest_tag=$(
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases/latest |
jq -r '.tag_name'
)
tags=${{ github.ref_name }}
if [ "${latest_tag}" == "${{ github.ref_name }}" ]; then
tags="${tags} latest"
fi
echo "RELEASE_TAGS=${tags}" >> $GITHUB_ENV
else
if [ -z "${{ github.event.inputs.release_tags }}" ]; then
exit 1
fi
echo "RELEASE_TAGS=${{ github.event.inputs.release_tags }}" >> $GITHUB_ENV
fi
- name: Build container image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
containerfiles: ./Containerfile
image: retis
tags: ${{ env.RELEASE_TAGS }}
- name: Push container image
id: push_image
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: quay.io/retis
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Summary
run: |
echo "${{ toJSON(steps.push_image.outputs) }}"