Skip to content

Commit

Permalink
Add github action build
Browse files Browse the repository at this point in the history
  • Loading branch information
babs committed Oct 14, 2024
1 parent 3c687d1 commit 1aad049
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Build OCI Image"

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
workflow_dispatch:

jobs:
build-image:
name: "Build OCI image"
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
attestations: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Define TARGETS
run: |
#REPOS="quay.io/${{ vars.QUAYIO_USERNAME }}/kaniko-w-ecr-repo-creator ghcr.io/${{ github.repository }}"
REPOS="quay.io/${{ vars.QUAYIO_USERNAME }}/kaniko-w-ecr-repo-creator ghcr.io/babs/kaniko-w-ecr-repo-creator"
IMG_TAGS="latest"
if [ ${GITHUB_REF_TYPE:-} == 'tag' -a -n "$(echo $GITHUB_REF_NAME | grep -iE '^v[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9.-]+)?$')" ]; then
TAG=${GITHUB_REF_NAME#v}
RELEASE=""
case "$TAG" in
*-*)
RELEASE="-${TAG#*-}"
;;
esac
SEMVER_CORE="${TAG%%-*}"
IMG_TAGS="${IMG_TAGS} $TAG ${SEMVER_CORE%.*}${RELEASE} ${SEMVER_CORE%%.*}${RELEASE}"
fi
echo "Targets:"
TARGETS=""
for REPO in $REPOS; do
for IMG_TAG in $IMG_TAGS; do
TARGETS="${TARGETS},${REPO}:${IMG_TAG}"
echo "- ${REPO}:${IMG_TAG}"
done
done
echo TARGETS=${TARGETS#,} >>$GITHUB_ENV
- uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAYIO_ROBOT_ACCOUNTNAME }}
password: ${{ secrets.QUAYIO_ROBOT_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ env.TARGETS }}
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ RUN set -xe \

FROM gcr.io/kaniko-project/executor:${KANIKO_VERSION}-debug AS final-stage

LABEL org.opencontainers.image.source=https://github.com/babs/ecr-repo-creator

COPY --from=ghcr.io/jqlang/jq /jq /usr/local/bin/
COPY --from=golang-am8-envsubst /go/bin/envsubst /usr/local/bin/
COPY --from=build-stage /app/ecr-repo-creator /usr/local/bin/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ For Kaniko version: https://github.com/GoogleContainerTools/kaniko/releases
For Golang version: https://hub.docker.com/_/golang


A prebuilt image of `kaniko` with `ecr-repo-creator` and `jq` is available at [beardedbabs/kaniko-w-ecr-repo-creator](https://hub.docker.com/r/beardedbabs/kaniko-w-ecr-repo-creator)
A prebuilt image of `kaniko` with `ecr-repo-creator`, `jq` and `envsubst` is available at [ghcr.io/babs/kaniko-w-ecr-repo-creator](https://github.com/babs/ecr-repo-creator/pkgs/container/kaniko-w-ecr-repo-creator)

```bash
docker pull beardedbabs/kaniko-w-ecr-repo-creator:latest
docker pull ghcr.io/babs/kaniko-w-ecr-repo-creator:1
```
2 changes: 1 addition & 1 deletion glci-example/templates/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ variables:
$[[ inputs.job_name ]]:
stage: $[[ inputs.stage ]]
image:
name: beardedbabs/kaniko-w-ecr-repo-creator:latest
name: ghcr.io/babs/kaniko-w-ecr-repo-creator:1
entrypoint: [""]
tags:
- $[[ inputs.runner_tags ]]
Expand Down

0 comments on commit 1aad049

Please sign in to comment.