Skip to content

Build

Build #39

Workflow file for this run

name: Build
permissions:
contents: read
packages: write
on:
workflow_dispatch:
workflow_call:
env:
HELM_FOLDER: helm
jobs:
images:
name: Build and push images
runs-on: ubuntu-22.04
strategy:
matrix:
targets: [{ name: capydemia, context: ./web }]
steps:
- name: Checkout repository contents
uses: actions/checkout@v4
- name: Generate image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ matrix.targets.name }}
flavor: |
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
- name: Build image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ matrix.targets.name }}
tags: ${{ steps.meta.outputs.tags }}
context: ${{ matrix.targets.context }}
containerfiles: ${{ matrix.targets.containerfile || format('{0}/Dockerfile', matrix.targets.context ) }}
- name: Push to GHCR
uses: redhat-actions/push-to-registry@v2
id: push
with:
tags: ${{ steps.build_image.outputs.tags }}
username: ${{ github.actor }}
password: ${{ github.token }}
helm:
name: Publish helm chart
runs-on: ubuntu-22.04
steps:
- name: Checkout repository contents
uses: actions/checkout@v4
- name: Setup Helm
uses: azure/[email protected]
with:
version: "3.16.2"
- name: Publish helm chart
env:
TOKEN: ${{ github.token }}
run: |
REGISTRY=$(echo "oci://ghcr.io/${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
echo $TOKEN | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
PKG_RESPONSE=$(helm package ${{ env.HELM_FOLDER }})
CHART_TAR_GZ=$(basename "$PKG_RESPONSE") # extract tar name from helm package stdout
helm push "$CHART_TAR_GZ" "$REGISTRY"