Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/docker-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: docker-build-push

on:
push:
branches:
- 'main'
tags:
- '*'

pull_request:
branches:
- 'main'

workflow_dispatch:

env:
IMAGE_NAME: "gitlab-monitor"

jobs:
docker:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2

- name: Prepare
id: prep
run: |
BASE_DIR=.
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME

# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')

# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')

# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest

VERSION=$VERSION
IMAGE_ID=$IMAGE_ID
echo ::set-output name=version::${VERSION}
echo ::set-output name=image_id::${IMAGE_ID}
echo ::set-output name=base_dir::${BASE_DIR}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
version: latest

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build and Push
uses: docker/build-push-action@v2
with:
build-args: VERSION=${{ steps.prep.outputs.version }}
context: ${{ steps.prep.outputs.base_dir }}/
file: ${{ steps.prep.outputs.base_dir }}/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ steps.prep.outputs.image_id }}:${{ steps.prep.outputs.version }}