Skip to content

Commit

Permalink
feat: Added workflow to build and push images to ghcr
Browse files Browse the repository at this point in the history
  • Loading branch information
shubms committed Dec 7, 2024
1 parent 154d6fa commit 190dde6
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Publish and Sign Container Image

env:
REGISTRY: ghcr.io

on:
push:
branches:
- main
paths:
- .github/workflows/build.yml
- "**/Containerfile"
# schedule:
# - cron: "17 07 * * 0"

jobs:
build-push-image:
runs-on: ubuntu-24.04

permissions:
contents: read
packages: write
id-token: write

strategy:
fail-fast: false
matrix:
include:
- image: spotify-distrobox
file: distroboxes/spotify/Containerfile
- image: steam-distrobox
file: distroboxes/steam/Containerfile

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache podman
uses: actions/cache@v3
with:
path: ~/.local/share/containers
key: podman

- name: Buildah image
uses: redhat-actions/buildah-build@v2
id: build
with:
image: ${{ matrix.image }}
tags: latest ${{ github.sha }}
containerfiles: |
${{ matrix.file }}
context: .
# oci: true
layers: true

- name: Push To GHCR
uses: redhat-actions/push-to-registry@v2
id: push
with:
image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }}
registry: ${{ env.REGISTRY }}/${{ github.repository_owner }}
username: ${{ github.repository_owner }}
password: ${{ github.token }}
# extra-args: |
# --sign-by-sigstore=.github/sigstore.yaml

- name: Cleanup old images
uses: actions/delete-package-versions@v5
with:
package-name: ${{ matrix.image }}
package-type: container
min-versions-to-keep: 60

0 comments on commit 190dde6

Please sign in to comment.