Build image #36
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-ignore: | |
- '**/README.org' | |
- '.github/dependabot.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 and push image | |
runs-on: ubuntu-22.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: | |
# Checkout push-to-registry action github repository | |
- name: Checkout Push to Registry action | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Install Cosign | |
uses: sigstore/[email protected] | |
# Build image using Buildah action | |
- 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 | |
# Push the image to GHCR (Image Registry) | |
- 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 | |
# Login to GHCR to sign the image | |
- 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 | |
run: | | |
cosign sign --yes --key env://COSIGN_PRIVATE_KEY ${{ env.IMAGE_REGISTRY }}/${{ steps.build_image.outputs.image }}@${DIGEST} | |
env: | |
DIGEST: ${{ steps.push.outputs.digest }} | |
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }} | |
- name: Echo outputs | |
run: | | |
echo "${{ toJSON(steps.push.outputs) }}" |