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

Add Container Image release workflow #389

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
44 changes: 44 additions & 0 deletions .github/workflows/container-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Container release

on:
push:
branches:
- master
schedule:
- cron: '5 5 * * 0'
Comment on lines +3 to +8
Copy link
Member

Choose a reason for hiding this comment

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

we have a release workflow, that runs on "tag is pushed" (https://github.com/theforeman/obal/blob/master/.github/workflows/release.yml), any reason not to hook it up there, instead of releasing on each push to master?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't push tags as much as we merge into master, that's why I did not added to this release workflow.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could add a new action/job to release new tags after merging to master, not sure how you or @ehelms feels about this.

Copy link
Member

@ekohl ekohl Apr 23, 2024

Choose a reason for hiding this comment

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

I think releasing more often would be a good thing. Not sure if after every commit would be a good thing though.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could have a job that runs weekly and do auto-tag/release if we have a commit stashed from the week prior.

Copy link
Member

Choose a reason for hiding this comment

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

I'd lean more to sumbitting a PR to release. It might be a bit more complicated, but I like the control. If we generalize it, I can see more repos in our org use it


env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: Containerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
19 changes: 16 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ env:
COLORTERM: 'yes'
TERM: 'xterm-256color'
PYTEST_ADDOPTS: '--color=yes'
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
Expand Down Expand Up @@ -42,9 +44,20 @@ jobs:
container:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run container tests
run: docker build --build-arg REPO=${GITHUB_REPOSITORY} --build-arg VERSION=${GITHUB_REF} -t quay.io/foreman/obal:$(echo ${GITHUB_REF} | tr '/' '_') .
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build container
uses: docker/build-push-action@v5
with:
file: Containerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
REPO=${{ github.repository }}
VERSION=${{ github.ref }}

lint:
runs-on: ubuntu-latest
Expand Down
10 changes: 6 additions & 4 deletions Dockerfile → Containerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM quay.io/centos/centos:stream8

RUN echo "tsflags=nodocs" >> /etc/yum.conf && \
yum -y install git glibc-langpack-en epel-release python3-pip 'dnf-command(config-manager)' && \
yum -y install git glibc-langpack-en epel-release python3.12-pip 'dnf-command(config-manager)' && \
yum clean all

ENV LANG=en_US.UTF-8 \
Expand All @@ -13,9 +13,11 @@ ARG VERSION=master
ARG REPO=theforeman/obal.git

RUN dnf config-manager --add-repo https://downloads.kitenet.net/git-annex/linux/current/rpms/git-annex.repo && \
pip3 install --upgrade pip && \
pip3 install git+https://github.com/${REPO}@${VERSION} && \
obal setup
pip3.12 install --upgrade pip && \
pip3.12 install git+https://github.com/${REPO}@${VERSION} && \
obal setup && \
dnf clean all


RUN mkdir -p /opt/packaging
WORKDIR /opt/packaging
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ include LICENSE
include .coveragerc
include .pylintrc
recursive-include rules *.py
exclude Dockerfile
exclude Containerfile