-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from aalexandru/devel-build-workflow
Release workflow to build and push docker images
- Loading branch information
Showing
6 changed files
with
109 additions
and
2 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,31 @@ | ||
name: release | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- 'release-*' | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
publish-docker-image-to-ghcr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Import environment variables from file | ||
run: cat ".github/env" >> $GITHUB_ENV | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '${{ env.golang-version }}' | ||
- name: Login to ghcr.io | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push Docker images | ||
run: make release |
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
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,6 @@ | ||
FROM alpine | ||
RUN apk add --update --no-cache ca-certificates | ||
ADD cluster-registry-api /bin/api | ||
USER nobody | ||
EXPOSE 8080 | ||
ENTRYPOINT ["/bin/api"] |
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,5 @@ | ||
FROM alpine | ||
RUN apk add --update --no-cache ca-certificates | ||
ADD cluster-registry-client /bin/client | ||
USER nobody | ||
ENTRYPOINT ["/bin/client"] |
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,34 @@ | ||
#!/usr/bin/env bash | ||
# exit immediately when a command fails | ||
set -e | ||
# only exit with zero if all commands of the pipeline exit successfully | ||
set -o pipefail | ||
|
||
REGISTRY="ghcr.io" | ||
|
||
export IMAGE_API="${IMAGE_API:-"adobe/cluster-registry-api"}" | ||
export IMAGE_CC="${IMAGE_CC:-"adobe/cluster-registry-client"}" | ||
export TAG="${GITHUB_REF##*/}" | ||
|
||
IMAGE_SUFFIX="-dev" | ||
|
||
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+ ]] || [ "${TAG}" == "main" ]; then | ||
IMAGE_SUFFIX="" | ||
else | ||
TAG="v$(cat "$(git rev-parse --show-toplevel)/VERSION")-$(git rev-parse --short HEAD)" | ||
fi | ||
|
||
API="${REGISTRY}/${IMAGE_API}${IMAGE_SUFFIX}" | ||
CC="${REGISTRY}/${IMAGE_CC}${IMAGE_SUFFIX}" | ||
|
||
for img in ${API} ${CC}; do | ||
echo "Building image: $img:$TAG" | ||
done | ||
|
||
make --always-make image TAG="${TAG}" | ||
|
||
docker tag "${IMAGE_API}:${TAG}" "${API}:${TAG}" | ||
docker tag "${IMAGE_CC}:${TAG}" "${CC}:${TAG}" | ||
|
||
docker push "${API}:${TAG}" | ||
docker push "${CC}:${TAG}" |