ci: build bazel container

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2023-07-25 15:00:49 +02:00
parent 0ab76a2f95
commit c8bc3ea5ee
2 changed files with 56 additions and 12 deletions

View File

@ -0,0 +1,56 @@
name: Build bazel dev container
on:
push:
branches:
- "main"
paths:
- "bazel/container/**"
workflow_dispatch:
jobs:
build-container:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Determine version
id: version
working-directory: ./bazel/container
run: |
version=$(grep "ARG BAZEL_VERSION" Containerfile | cut -d= -f2)
echo "version=${version}" | tee -a "$GITHUB_OUTPUT"
- name: Docker meta
id: meta
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # v4.6.0
with:
images: |
ghcr.io/edgelesssys/bazel-container
flavor: |
latest=false
tags: |
type=raw,value=${{ steps.version.outputs.version }},enable=${{ github.ref_name == 'main' }}
type=raw,value=${{ github.ref_name }},enable=${{ github.ref_name != 'main' }}
type=sha,value=${{ github.sha }}
type=raw,value=latest,enable=${{ github.ref_name == 'main' }}
- name: Log in to the Container registry
uses: ./.github/actions/container_registry_login
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push container image
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # v4.1.1
with:
context: ./bazel/container
file: ./bazel/container/Containerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -1,12 +0,0 @@
export DOCKER_BUILDKIT=1
CONTAINER_NAME := ghcr.io/edgelesssys/bazel-container
CONTAINER_VERSION := v6.1.2-0
.PHONY: container container-push
container:
docker build -f Containerfile -t "$(CONTAINER_NAME):$(CONTAINER_VERSION)" .
container-push:
docker push "$(CONTAINER_NAME):$(CONTAINER_VERSION)"