Skip to content

Commit 1ad7a89

Browse files
authored
Merge pull request #190 from akostadinov/master
workflow to build container images
2 parents 06643a7 + 30083f9 commit 1ad7a89

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Container Image
2+
3+
on:
4+
workflow_dispatch: {}
5+
workflow_call: {}
6+
schedule:
7+
# every Wednesday morning
8+
- cron: 7 7 * * 3
9+
push:
10+
branches: [ master ]
11+
tags:
12+
- '*' # Push events to every tag not containing /
13+
pull_request:
14+
types: [opened, reopened, synchronize]
15+
16+
concurrency:
17+
group: ci-container-build-${{ github.ref }}-1
18+
cancel-in-progress: true
19+
20+
env:
21+
# Use docker.io for Docker Hub if empty
22+
REGISTRY: ghcr.io
23+
# github.repository as <account>/<repo>
24+
IMAGE_NAME: ${{ github.repository }}
25+
26+
# Sets permissions of the GITHUB_TOKEN to allow deployment to ghcr.io
27+
permissions:
28+
contents: read
29+
packages: write
30+
id-token: write
31+
32+
jobs:
33+
buildah:
34+
runs-on: ubuntu-latest
35+
steps:
36+
# Allow multi-target builds
37+
- name: Set up QEMU
38+
uses: docker/setup-qemu-action@v2
39+
with:
40+
platforms: arm64
41+
# Login against a Docker registry except on PR
42+
# https://github.com/docker/login-action
43+
- name: Log into registry ${{ env.REGISTRY }}
44+
if: github.event_name != 'pull_request'
45+
uses: redhat-actions/podman-login@v1
46+
with:
47+
registry: ${{ env.REGISTRY }}
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
# Extract metadata (tags, labels) for Docker
51+
# https://github.com/docker/metadata-action
52+
- name: Docker meta
53+
id: meta
54+
uses: docker/metadata-action@v4
55+
with:
56+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
57+
tags: |
58+
type=schedule
59+
type=raw,value=latest,enable=${{ github.ref_name == 'master' }}
60+
${{ github.ref_name == 'master' && 'type=raw,value=nightly' || 'type=ref,event=branch' }}
61+
type=ref,event=tag
62+
type=ref,event=pr
63+
64+
# https://github.com/actions/checkout
65+
- uses: actions/checkout@v3
66+
67+
- name: Build image
68+
id: build-image
69+
uses: redhat-actions/buildah-build@v2
70+
with:
71+
tags: ${{ steps.meta.outputs.tags }}
72+
platforms: linux/amd64
73+
labels: ${{ steps.meta.outputs.labels }}
74+
layers: false
75+
oci: true
76+
tls-verify: true
77+
extra-args: |
78+
--squash
79+
--jobs=3
80+
containerfiles: |
81+
Dockerfile
82+
83+
- name: Echo Outputs
84+
run: |
85+
echo "Image: ${{ steps.build-image.outputs.image }}"
86+
echo "Tags: ${{ steps.build-image.outputs.tags }}"
87+
echo "Tagged Image: ${{ steps.build-image.outputs.image-with-tag }}"
88+
89+
- name: Check images created
90+
run: buildah images
91+
92+
- name: Push To Container Registry
93+
id: push-to-container-registry
94+
uses: redhat-actions/push-to-registry@v2
95+
if: github.event_name != 'pull_request'
96+
with:
97+
tags: ${{ steps.build-image.outputs.tags }}
98+
99+
- name: Print image url
100+
run: echo "Image pushed to ${{ steps.push-to-container-registry.outputs.registry-paths }}"

0 commit comments

Comments
 (0)