Skip to content

Commit 29fcfa6

Browse files
committed
github: Build and push container image for pull requests
This change adds container builds for pull requests. For two reasons: 1) In case of failures on the main branch, to check whether a pull request aiming to fix them really fixes them. 2) Might be nice for testing someones' changes before merging, without necessity to check out and build their code. Signed-off-by: Michal Rostecki <[email protected]>
1 parent 9b9931a commit 29fcfa6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

.github/workflows/container-image.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
- main
55
tags:
66
- 'v*'
7+
pull_request:
8+
branches:
9+
- main
710

811
name: build container image
912

@@ -33,12 +36,36 @@ jobs:
3336
if: ${{ startsWith(github.ref, 'refs/heads/') }}
3437
uses: docker/build-push-action@v2
3538
with:
39+
build-args: |
40+
PROFILE=debug
3641
context: .
3742
file: ./Dockerfile
3843
platforms: linux/amd64, linux/arm64
3944
push: true
4045
tags: |
4146
ghcr.io/rancher-sandbox/lockc:latest
47+
-
48+
name: Retrieve pull request number
49+
if: ${{ startsWith(github.ref, 'refs/pull/') }}
50+
run: |
51+
echo PR_NUMBER=$(echo $GITHUB_REF | sed -e "s|^refs/pull/||" -e "s|/merge$||")
52+
-
53+
name: Build and push pull request container image
54+
if: ${{ startsWith(github.ref, 'refs/pull/') }}
55+
uses: docker/build-push-action@v2
56+
with:
57+
build-args:
58+
PROFILE=debug
59+
context: .
60+
file: ./Dockerfile
61+
platforms: linux/amd64, linux/arm64
62+
push: true
63+
tags: |
64+
ghcr.io/rancher-sandbox/lockc:pr${{ env.PR_NUMBER }}
65+
-
66+
name: Get ref
67+
run: |
68+
echo $GITHUB_REF
4269
-
4370
name: Retrieve tag name
4471
if: ${{ startsWith(github.ref, 'refs/tags/') }}
@@ -49,6 +76,8 @@ jobs:
4976
if: ${{ startsWith(github.ref, 'refs/tags/') }}
5077
uses: docker/build-push-action@v2
5178
with:
79+
build-args: |
80+
PROFILE=release
5281
context: .
5382
file: ./Dockerfile
5483
platforms: linux/amd64

0 commit comments

Comments
 (0)