Skip to content

Building CC-Job-Image-Base #2

Building CC-Job-Image-Base

Building CC-Job-Image-Base #2

name: Build CC-Job-Image-Base
run-name: Building CC-Job-Image-Base
on:
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
environment: build
permissions:
contents: read
packages: write
env:
platforms: linux/amd64,linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Docker-Buildx
uses: docker/setup-buildx-action@v3
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ env.platforms }}
- name: docker-auth
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- name: Read Version
id: read_version
run: |
version=$(cat JOB_IMAGE_BASE_VERSION)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Build and Push Base Image
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/${{ github.repository_owner }}/cc-utils/job-image-base:${{ steps.read_version.outputs.version }}
file: Dockerfile.job-image-base
update-base-image-version:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
new_version: ${{ steps.update_version.outputs.new_version }}
current_version: ${{ steps.update_version.outputs.current_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Git Identity
uses: ./.github/actions/setup-git-identity
- name: Update Base Image and Increment Version
id: update_version
run: |
current_version=$(cat JOB_IMAGE_BASE_VERSION)
sed -i "s|^ARG BASE_IMAGE=.*|ARG BASE_IMAGE=ghcr.io/${{ github.repository_owner }}\
/cc-utils/job-image-base:$current_version|" Dockerfile
new_version=$(echo $current_version | awk -F. '{printf "%d.%d.%d", $1, $2+1, $3}')
echo "new_version=$new_version" >> $GITHUB_OUTPUT
echo "current_version=$current_version" >> $GITHUB_OUTPUT
echo "$new_version" > JOB_IMAGE_BASE_VERSION
- name: Commit and Push Changes
run: |
git add Dockerfile JOB_IMAGE_BASE_VERSION
git commit -m "Update job-image to use job-image-base \
version ${{ steps.update_version.outputs.current_version }} \
and prepare for ${{ steps.update_version.outputs.new_version }}"
git checkout -b update-base-image
git push origin update-base-image --force
- name: Create Pull Request
run: |
gh pr create \
-B master \
-H update-base-image \
--title "Update job-image to use version ${{ steps.update_version.outputs.current_version }}" \
--body "Updates the job-image to use the latest job-image-base version:
- Base Image Version: ${{ steps.update_version.outputs.current_version }}.
- Also increments the version to ${{ steps.update_version.outputs.new_version }}."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}