forked from microcumulus/ca-injector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Removed chart release workflow and added container build workflow * Used GitHub Container Registry docker login
- Loading branch information
Showing
2 changed files
with
93 additions
and
13 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,93 @@ | ||
name: release | ||
|
||
on: | ||
schedule: | ||
- cron: '0 22 * * 0' # every sunday at 10pm | ||
push: | ||
branches: | ||
- 'main' | ||
tags: | ||
- 'v?[0-9]+.[0-9]+.[0-9]+*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Check out repository | ||
uses: actions/checkout@v2 | ||
- | ||
name: Set build variables | ||
id: env | ||
run: | | ||
REGISTRY=ghcr.io/ | ||
IMAGE=zeiss/ca-injector | ||
VERSION=noop | ||
if [ "${{ github.event_name }}" = "schedule" ]; then | ||
VERSION=edge | ||
elif [[ $GITHUB_REF == refs/tags/* ]]; then | ||
VERSION=${GITHUB_REF#refs/tags/} | ||
elif [[ $GITHUB_REF == refs/heads/* ]]; then | ||
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | ||
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then | ||
VERSION=edge | ||
fi | ||
elif [[ $GITHUB_REF == refs/pull/* ]]; then | ||
VERSION=pr-${{ github.event.number }} | ||
fi | ||
TAGS="${REGISTRY}${IMAGE}:${VERSION}" | ||
if [[ $VERSION =~ ^v?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | ||
VERSION_STRIP=${VERSION#v} | ||
MINOR=${VERSION_STRIP%.*} | ||
MAJOR=${MINOR%.*} | ||
TAGS="$TAGS,${REGISTRY}${IMAGE}:${MINOR},${REGISTRY}${IMAGE}:${MAJOR},${REGISTRY}${IMAGE}:latest" | ||
# elif [ "${{ github.event_name }}" = "push" ]; then | ||
# TAGS="$TAGS,${REGISTRY}${IMAGE}:sha-${GITHUB_SHA::8}" | ||
fi | ||
echo ::set-output name=version::${VERSION} | ||
echo ::set-output name=tags::${TAGS} | ||
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
with: | ||
config-inline: | | ||
[worker.oci] | ||
max-parallelism = 4 | ||
- | ||
name: Check out Docker Buildx cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- | ||
name: Login to GitHub Container Registry | ||
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 image | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.env.outputs.tags }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
labels: | | ||
org.opencontainers.image.created=${{ steps.env.outputs.created }} | ||
org.opencontainers.image.source=https://github.com/${{ github.repository }} | ||
org.opencontainers.image.version=${{ steps.env.outputs.version }} | ||
org.opencontainers.image.revision=${{ github.sha }} | ||
org.opencontainers.image.licenses=${{ github.event.repository.license.name }} |