File tree Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ name: Build and publish
22
33on :
44 pull_request :
5+ types :
6+ - closed
57 branches :
68 - main
79 release :
Original file line number Diff line number Diff line change 1+ name : Build and push image from PR
2+
3+ on :
4+ pull_request :
5+ types : [opened, synchronize, reopened]
6+
7+ jobs :
8+ build :
9+ name : Build and push image from PR
10+ runs-on : ubuntu-latest
11+ permissions :
12+ contents : read
13+ packages : write
14+
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v3
18+
19+ - name : Log in to ghcr
20+ uses : docker/login-action@v2
21+ with :
22+ registry : ghcr.io
23+ username : ${{ github.actor }}
24+ password : ${{ secrets.GITHUB_TOKEN }}
25+
26+ - name : Build the image
27+ run : make build
28+
29+ - name : Push PR image to the registry
30+ run : make pr-image
31+ env :
32+ TAG : ${{ github.head_ref }}
Original file line number Diff line number Diff line change @@ -12,5 +12,9 @@ publish:
1212 @test -n " ${TAG} " || ( echo " TAG environment variable must be set" && return 1 )
1313 ./scripts/publish.sh $(IMAGE_NAME ) ${TAG}
1414
15+ pr-image :
16+ @test -n " ${TAG} " || ( echo " TAG environment variable must be set" && return 1 )
17+ ./scripts/pr-image.sh $(IMAGE_NAME ) ${TAG}
18+
1519help :
1620 @sed -ne ' /@sed/!s/## //p' $(MAKEFILE_LIST )
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # Push images built off a PR to Github Container Registry
4+
5+ set -e
6+
7+ if [ " $# " -ne 2 ]; then
8+ >&2 echo " Usage: $( basename $0 ) <image-name> <branch-tag>"
9+ exit 1
10+ fi
11+
12+ IMAGE_NAME=" $1 "
13+ BRANCH=$( echo " ${2} " | sed ' s/\//-/g' )
14+
15+ echo " 🏷️ Setting tags for image '${IMAGE_NAME} :${BRANCH} -prbase"
16+ docker tag " ${IMAGE_NAME} :base" " ${IMAGE_NAME} :${BRANCH} -prbase"
17+
18+ echo " 📤 Pushing '${IMAGE_NAME} :${BRANCH} -prbase'"
19+ docker push " ${IMAGE_NAME} :${BRANCH} -prbase"
You can’t perform that action at this time.
0 commit comments