Skip to content

Commit a22d733

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 d0e3471 commit a22d733

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

.github/workflows/container-image.yml

Lines changed: 22 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

@@ -39,6 +42,25 @@ jobs:
3942
push: true
4043
tags: |
4144
ghcr.io/rancher-sandbox/lockc:latest
45+
-
46+
name: Retrieve pull request number
47+
if: ${{ startsWith(github.ref, 'refs/pull/') }}
48+
run: |
49+
echo PR_NUMBER=$(echo $GITHUB_REF | sed -e "s|^refs/pull/||" -e "s|/merge$||")
50+
-
51+
name: Build and push pull request container image
52+
if: ${{ startsWith(github.ref, 'refs/pull/') }}
53+
users: docker/build-push-action@v2
54+
with:
55+
context: .
56+
file: ./Dockerfile
57+
platforms: linux/amd64, linux/arm64
58+
push: true
59+
tags: |
60+
ghcr.io/rancher-sandbox/lockc:pr${{ env.PR_NUMBER }}
61+
- name: Get ref
62+
run: |
63+
echo $GITHUB_REF
4264
-
4365
name: Retrieve tag name
4466
if: ${{ startsWith(github.ref, 'refs/tags/') }}

0 commit comments

Comments
 (0)