Skip to content

Build uChill Image #132

Build uChill Image

Build uChill Image #132

Workflow file for this run

## ~ UbioZur - https://github.com ~ ##
---
name: Build uChill Image
on:
# Run on a schedule every UTC Monday & Thursday 23:00
# or JST Tuesday & Friday 8:00
# only run on default branch (main)
schedule:
- cron: "0 23 * * MON,THU"
# Run on push of the main and dev branch
push:
branches:
- main
- dev
paths:
- "src/**"
# Partially run on pull_request (only check build)
pull_request:
branches:
- main
- dev
paths:
- "src/**"
# Manual trigger when needed
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}-${{ inputs.brand_name}}-${{ inputs.stream_name }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
nvidia: ["N", "Y"]
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Clean up some space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
docker-images: false
- name: Checkout Code
uses: actions/checkout@v4
- name: Load environement file
run: |
file=".env"
source "$file"
while IFS='=' read -r key value; do
if [[ ! $key =~ ^# && -n $key ]]; then
echo "$key=$value" >> $GITHUB_ENV
fi
done < $file
NVIDIA="${{ matrix.nvidia }}"
echo "NVIDIA=${NVIDIA}" >> $GITHUB_ENV
[[ "${NVIDIA}" == "Y" ]] && VARIANT="-nvidia" || VARIANT=""
FULLNAME=${IMAGE_NAME,,}${VARIANT,,}
[[ "${{ github.ref_name }}" != "main" ]] && FULLNAME=${FULLNAME}-${{ github.ref_name }}
echo "FULLNAME=${FULLNAME}" >> $GITHUB_ENV
echo "DATE=$(date -u +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "DATELONG=$(date -u +%Y\-%m\-%d\T%H\:%M\:%S\Z)" >> $GITHUB_ENV
# Handle the description (Use the repository description)
repo="${GITHUB_REPOSITORY}"
desc=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/${repo}" | jq -r .description)
echo "DESC=$desc" >> $GITHUB_ENV
- name: Image Metadata
uses: docker/metadata-action@v5
id: metadata
with:
tags: |
type=raw,value=latest
type=raw,value=${{ env.BASE_VERSION }}
type=raw,value=${{ env.BASE_VERSION }}-${{ env.DATE }}
labels: |
org.opencontainers.image.created=${{ env.DATELONG }}
org.opencontainers.image.description="${{ env.DESC }}"
org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.url=https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}
org.opencontainers.image.vendor=${{ github.repository_owner }}
org.opencontainers.image.version=${{ env.BASE_VERSION }}-${{ env.DATE }}
containers.bootc=1
sep-tags: " "
sep-annotations: " "
- name: Build Container Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
context: src
containerfiles: src/Containerfile
image: ${{ env.FULLNAME }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
oci: false
build-args: NVIDIA=${{ env.NVIDIA }}
# From now, only do on schedule and push
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request' || (github.ref_name == 'dev' && github.event_name == 'push')
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push To GHCR
uses: redhat-actions/push-to-registry@v2
if: github.event_name != 'pull_request' || (github.ref_name == 'dev' && github.event_name == 'push')
id: push
env:
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
with:
registry: ghcr.io/ubiozur
image: ${{ env.FULLNAME }}
tags: ${{ steps.metadata.outputs.tags }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Install Cosign
uses: sigstore/cosign-installer@v3.8.2
if: github.event_name != 'pull_request' || (github.ref_name == 'dev' && github.event_name == 'push')
- name: Sign container image
if: github.event_name != 'pull_request' || (github.ref_name == 'dev' && github.event_name == 'push')
run: |
IMAGE_FULL="ghcr.io/ubiozur/${{ env.FULLNAME }}"
for tag in ${{ steps.metadata.outputs.tags }}; do
cosign sign -y --key env://COSIGN_PRIVATE_KEY $IMAGE_FULL:$tag
done
env:
TAGS: ${{ steps.push.outputs.digest }}
COSIGN_EXPERIMENTAL: false
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}
# notify_success:
# needs: build
# if: success()
# runs-on: ubuntu-latest
# steps:
# - name: Send Matrix success notification
# uses: fadenb/matrix-chat-message@v0.0.6
# with:
# homeserver: "matrix.org"
# token: ${{ secrets.MATRIX_TOKEN }}
# channel: ${{ secrets.MATRIX_CHANNEL }}
# message: |
# ✅ GitHub Action ${{ github.workflow }} completed successfully!
# Commit: ${{ github.sha }}
# NVidia: ${{ needs.build.outputs.nvidia }}
# notify_failure:
# needs: build
# if: failure()
# runs-on: ubuntu-latest
# steps:
# - name: Send Matrix success notification
# uses: fadenb/matrix-chat-message@v0.0.6
# with:
# homeserver: "matrix.org"
# token: ${{ secrets.MATRIX_TOKEN }}
# channel: ${{ secrets.MATRIX_CHANNEL }}
# message: |
# 🚨 GitHub Action ${{ github.workflow }} **FAILED**!
# Commit: ${{ github.sha }}
# NVidia: ${{ needs.build.outputs.nvidia }}
# <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View failed run>