Skip to content

Commit fb6aed8

Browse files
authored
Merge pull request #2 from weaveworks/gh-actions
Add build tooling
2 parents fc7eaa0 + 17e137e commit fb6aed8

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

.github/workflows/build.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Build and push docker container"
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
jobs:
8+
cluster-bootstrap-controller:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Install Go
12+
uses: actions/setup-go@v2
13+
with:
14+
go-version: 1.17.x
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
ref: ${{ github.event.pull_request.head.sha }}
20+
- name: Build docker image
21+
run: |
22+
make docker-build
23+
- name: Login to Docker Hub
24+
uses: docker/login-action@v1
25+
with:
26+
registry: docker.io
27+
username: ${{ secrets.WGE_DOCKER_IO_USER }}
28+
password: ${{ secrets.WGE_DOCKER_IO_PASSWORD }}
29+
- name: Push image to docker registry
30+
run: |
31+
make docker-push
32+
33+

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
2929
#
3030
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
3131
# weave.works/cluster-bootstrap-controller-bundle:$VERSION and weave.works/cluster-bootstrap-controller-catalog:$VERSION.
32-
IMAGE_TAG_BASE ?= weave.works/cluster-bootstrap-controller
32+
IMAGE_TAG_BASE ?= weaveworks/cluster-bootstrap-controller
3333

3434
# BUNDLE_IMG defines the image:tag used for the bundle.
3535
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
3636
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
3737

38+
IMAGE_TAG := $(shell tools/image-tag)
3839
# Image URL to use all building/pushing image targets
39-
IMG ?= controller:latest
40+
IMG ?= $(IMAGE_TAG_BASE):$(IMAGE_TAG)
4041
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
4142
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
4243
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.

tools/image-tag

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
REF="${1:-"HEAD"}"
8+
9+
WORKING_SUFFIX=$(if git status --porcelain | grep -qE '^(?:[^?][^ ]|[^ ][^?])\s'; then echo "-WIP"; else echo ""; fi)
10+
CURRENT_TAG=$(if TAG=$(git describe --tags --exact-match "$REF" 2>/dev/null); then echo $TAG; else echo ""; fi)
11+
if test -z "$WORKING_SUFFIX" && test ! -z "$CURRENT_TAG"
12+
then
13+
echo $CURRENT_TAG
14+
else
15+
BRANCH_PREFIX=$(git rev-parse --abbrev-ref "$REF")
16+
17+
# Fix the object name prefix length to 8 characters to have it consistent across the system.
18+
# See https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---shortlength
19+
echo "${BRANCH_PREFIX//\//-}-$(git rev-parse --short=8 "$REF")$WORKING_SUFFIX"
20+
fi

0 commit comments

Comments
 (0)