Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH Actions: Build with buildah #1

Merged
merged 6 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
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
79 changes: 79 additions & 0 deletions .github/workflows/buildah.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build dnsmasq oci container image

on:
push:
branches:
- gh-actions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only to this branch? not main/master?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this. It was for testing. I couldn't find another way to make the action run.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you have workflow_dispatch then you can start it manually

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't, until the job appeared for the first time in the Actions tab. And for that I had to add the push launcher.

workflow_dispatch:
inputs:
custom_tag:
description: optional custom tag on remote repo you want image to be tagged with
required: false
default: 'latest'
type: string

env:
# Use docker.io for Docker Hub if empty
REGISTRY: quay.io
IMAGE_NAME: 3scale/dnsmasq

jobs:
buildah:
runs-on: ubuntu-latest
steps:
- name: Log in to Red Hat Registry
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_USER_NAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=schedule
type=ref,event=branch,enable=${{ github.ref_name != 'main' && inputs.custom_tag == '' }}
type=raw,value=latest,enable=${{ github.ref_name == 'main' }}
type=raw,value=nightly,enable=${{ github.ref_name == 'main' }}
${{ inputs.custom_tag }}
type=ref,event=tag
type=ref,event=pr

- uses: actions/checkout@v4

- name: Build image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
layers: false
oci: true
tls-verify: true
extra-args: |
--squash
containerfiles: |
Containerfile

- name: Echo Outputs
run: |
echo "Image: ${{ steps.build-image.outputs.image }}"
echo "Tags: ${{ steps.build-image.outputs.tags }}"
echo "Tagged Image: ${{ steps.build-image.outputs.image-with-tag }}"

- name: Check images created
run: buildah images

- name: Push To quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
if: github.event_name != 'pull_request'
with:
tags: ${{ steps.build-image.outputs.tags }}

- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"

4 changes: 2 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM registry.access.redhat.com/ubi9/ubi

LABEL maintainer="3scale system team <[email protected]>"
LABEL org.opencontainers.image.title="dnsmasq",
LABEL org.opencontainers.image.source="https://github.com/3scale/dnsmasq"
LABEL org.opencontainers.image.vendor="3scale"

FROM registry.access.redhat.com/ubi9/ubi

RUN dnf -y install dnsmasq
EXPOSE 53 67 69
ENTRYPOINT ["/usr/sbin/dnsmasq"]
Expand Down