-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
91 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: PR Automation | ||
|
||
on: | ||
pull_request: {} | ||
|
||
jobs: | ||
publish-branch-images: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Determine Go version from go.mod | ||
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV | ||
|
||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Login to GHCR | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build branch and push AppCat | ||
run: make docker-push-branchtag | ||
|
||
- name: Build branch and push Functions | ||
run: make function-push-package-branchtag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Image URL to use all building/pushing image targets | ||
IMG_TAG ?= latest | ||
GHCR_IMG ?= ghcr.io/vshn/appcat:$(IMG_TAG) | ||
DOCKER_CMD ?= docker | ||
|
||
# For alpine image it is required the following env before building the application | ||
DOCKER_IMAGE_GOOS = linux | ||
DOCKER_IMAGE_GOARCH = amd64 | ||
|
||
.PHONY: docker-build | ||
docker-build: | ||
env CGO_ENABLED=0 GOOS=$(DOCKER_IMAGE_GOOS) GOARCH=$(DOCKER_IMAGE_GOARCH) \ | ||
go build -o ${BIN_FILENAME} | ||
docker build --platform $(DOCKER_IMAGE_GOOS)/$(DOCKER_IMAGE_GOARCH) -t ${GHCR_IMG} . | ||
|
||
.PHONY: docker-build-branchtag | ||
IMG_TAG = $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') | ||
docker-build-branchtag: docker-build ## Build docker image with current branch name | ||
|
||
.PHONY: docker-push | ||
docker-push: docker-build ## Push docker image with the manager. | ||
docker push ${GHCR_IMG} | ||
|
||
.PHONY: docker-push-branchtag | ||
IMG_TAG = $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') | ||
docker-push-branchtag: docker-build-branchtag docker-push ## Push docker image with current branch name | ||
|
||
.PHONY: function-build | ||
function-build: docker-build | ||
yq e '.spec.image="${GHCR_IMG}"' package/crossplane.yaml.template > package/crossplane.yaml | ||
rm -f package/*.xpkg | ||
go run github.com/crossplane/crossplane/cmd/[email protected] xpkg build -f package --verbose --embed-runtime-image=${GHCR_IMG} -o package/package-function-appcat.xpkg | ||
git checkout package/crossplane.yaml | ||
|
||
.PHONY: function-push-package | ||
function-push-package: function-build | ||
go run github.com/crossplane/crossplane/cmd/[email protected] xpkg push -f package/package-function-appcat.xpkg ghcr.io/vshn/appcat:${IMG_TAG}-func --verbose | ||
|
||
.PHONY: function-build-branchtag | ||
IMG_TAG = $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') | ||
function-build-branchtag: docker-build-branchtag | ||
yq e '.spec.image="${GHCR_IMG}"' package/crossplane.yaml.template > package/crossplane.yaml | ||
rm -f package/*.xpkg | ||
go run github.com/crossplane/crossplane/cmd/[email protected] xpkg build -f package --verbose --embed-runtime-image=${GHCR_IMG} -o package/package-function-appcat.xpkg | ||
git checkout package/crossplane.yaml | ||
|
||
.PHONY: function-push-package-branchtag | ||
IMG_TAG = $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') | ||
function-push-package-branchtag: function-build-branchtag | ||
go run github.com/crossplane/crossplane/cmd/[email protected] xpkg push -f package/package-function-appcat.xpkg ${GHCR_IMG}-func --verbose |
This file was deleted.
Oops, something went wrong.