Build image #246
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: Build image | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '**' | |
- '!**/README.org' | |
- '!.github/**' | |
- '.github/workflows/build.yml' | |
workflow_dispatch: | |
schedule: | |
# Build every day at 6:00 a.m. | |
# Fedora Silverblue image is built at 4:00 a.m. | |
- cron: '0 6 * * *' | |
env: | |
IMAGE_NAME: ${{ github.event.repository.name }} | |
IMAGE_TAGS: latest ${{ github.sha }} | |
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} | |
REGISTRY_USER: ${{ github.actor }} | |
REGISTRY_PASSWORD: ${{ github.token }} | |
jobs: | |
build-push: | |
name: Build, push and sign image | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
permissions: | |
contents: read | |
packages: write # needed for pushing package to GHCR | |
#id-token: write # needed for signing the images with GitHub OIDC Token | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Install Cosign | |
uses: sigstore/cosign-installer@v3.7.0 | |
- name: Build image | |
id: build_image | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
containerfiles: ./Containerfile | |
image: ${{ env.IMAGE_NAME }} | |
tags: ${{ env.IMAGE_TAGS }} | |
oci: true | |
- name: Push to registry | |
uses: redhat-actions/push-to-registry@v2 | |
id: push | |
with: | |
image: ${{ steps.build_image.outputs.image }} | |
tags: ${{ steps.build_image.outputs.tags }} | |
registry: ${{ env.IMAGE_REGISTRY }} | |
username: ${{ env.REGISTRY_USER }} | |
password: ${{ env.REGISTRY_PASSWORD }} | |
extra-args: | | |
--disable-content-trust | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ env.REGISTRY_USER }} | |
password: ${{ env.REGISTRY_PASSWORD }} | |
- name: Sign image with a key | |
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable | |
run: | | |
cosign sign --yes --key env://COSIGN_PRIVATE_KEY ${REGISTRY}/${NAME}@${DIGEST} | |
env: | |
REGISTRY: ${{ env.IMAGE_REGISTRY }} | |
NAME: ${{ steps.build_image.outputs.image }} | |
DIGEST: ${{ steps.push.outputs.digest }} | |
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }} | |
- name: Echo outputs | |
run: | | |
echo "${{ toJSON(steps.push.outputs) }}" |