Skip to content

Commit 56b4669

Browse files
committed
github: workflow: add logic to build a container image
Signed-off-by: Antoine Tenart <[email protected]>
1 parent 9a750f1 commit 56b4669

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build and push a container image
2+
3+
on: [workflow_dispatch]
4+
5+
jobs:
6+
build-and-push-image:
7+
runs-on: ubuntu-latest
8+
9+
permissions:
10+
packages: write
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Build image
16+
id: build_image
17+
uses: redhat-actions/buildah-build@v2
18+
with:
19+
containerfiles: Containerfile
20+
image: sniproxy
21+
tags: "latest"
22+
23+
- name: Push image
24+
uses: redhat-actions/push-to-registry@v2
25+
with:
26+
image: ${{ steps.build_image.outputs.image }}
27+
tags: ${{ steps.build_image.outputs.tags }}
28+
registry: ghcr.io/${{ github.repository_owner }}
29+
username: ${{ github.actor }}
30+
password: ${{ github.token }}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Daily check for new commits in main
2+
3+
on:
4+
# Every day at 01:42 AM UTC.
5+
schedule:
6+
- cron: "42 01 * * *"
7+
8+
jobs:
9+
daily-change-check:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Check for new commits in main and trigger actions
16+
run: |
17+
if [ -z "$(git log -n1 --since=yesterday --oneline)" ]; then
18+
exit 0
19+
fi
20+
gh workflow run build_container.yaml
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)