Image #304
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Image | |
on: | |
schedule: | |
- cron: 22 9 * * * | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: {} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-24.04 | |
permissions: | |
contents: read | |
packages: write | |
# This is used to complete the identity challenge | |
# with sigstore/fulcio when running outside of PRs. | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Install the cosign tool except on PR | |
# https://github.com/sigstore/cosign-installer | |
- name: Install cosign | |
if: github.event_name != 'pull_request' | |
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0 | |
with: | |
cosign-release: 'v2.2.4' | |
# Set up BuildKit Docker container builder to be able to build | |
# multi-platform images and export cache | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 | |
# Login against a Docker registry except on PR | |
# https://github.com/docker/login-action | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build Image | |
id: build_image | |
run: | | |
sudo buildah build \ | |
--format "docker" \ | |
--tag raw-img . | |
# Reprocess raw-img using rechunk which will delete it | |
- uses: hhd-dev/[email protected] | |
id: rechunk | |
with: | |
rechunk: 'ghcr.io/hhd-dev/rechunk:v0.8.6' | |
ref: 'raw-img' | |
prev-ref: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main" | |
skip_compression: true | |
version: main | |
- name: Load in podman and tag | |
run: | | |
IMAGE=$(podman pull ${{ steps.rechunk.outputs.ref }}) | |
sudo rm -rf ${{ steps.rechunk.outputs.output }} | |
podman tag $IMAGE ${{ env.IMAGE_NAME }}:main | |
- name: Push To GHCR | |
uses: redhat-actions/push-to-registry@v2 | |
if: github.event_name != 'pull_request' | |
id: push | |
with: | |
registry: ${{ env.REGISTRY }} | |
image: ${{ env.IMAGE_NAME }} | |
tags: main | |
extra-args: | | |
--disable-content-trust | |
- name: Sign container image | |
if: github.event_name != 'pull_request' | |
run: | | |
cosign sign -y ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${TAGS} | |
env: | |
TAGS: ${{ steps.push.outputs.digest }} |