Compare commits
9 Commits
023f2e8958
...
v2
| Author | SHA1 | Date | |
|---|---|---|---|
|
956337b9bd
|
|||
|
d062ec1f98
|
|||
|
478763d87d
|
|||
|
5e558b2b23
|
|||
|
a053eb45d2
|
|||
|
9798363981
|
|||
|
e0de3bb4b5
|
|||
|
74862f84ee
|
|||
|
ef78704b98
|
@@ -3,9 +3,6 @@ name: Build and deploy
|
|||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
generate_crds:
|
|
||||||
description: Runs a binary called gencrd in the docker container and writes the output to ./manifests/crds.yaml
|
|
||||||
type: boolean
|
|
||||||
push_manifests:
|
push_manifests:
|
||||||
description: Push manifest files to OCI repository
|
description: Push manifest files to OCI repository
|
||||||
default: true
|
default: true
|
||||||
@@ -15,18 +12,17 @@ on:
|
|||||||
type: string
|
type: string
|
||||||
outputs:
|
outputs:
|
||||||
images:
|
images:
|
||||||
value: ${{ jobs.images.outputs.images }}
|
value: ${{ jobs.build.outputs.images }}
|
||||||
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
OCI_REPO: git.huizinga.dev/dreaded_x/${{ gitea.event.repository.name}}
|
OCI_REPO: git.huizinga.dev/${{ gitea.repository_owner}}/${{gitea.event.repository.name}}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build container and manifests
|
name: Build container and manifests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
metadata: ${{ steps.build.outputs.metadata }}
|
images: ${{ steps.images.outputs.images }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -49,12 +45,12 @@ jobs:
|
|||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Install kustomize
|
- name: Install kustomize
|
||||||
if: inputs.push_manifests == true
|
if: inputs.push_manifests == 'true'
|
||||||
run: |
|
run: |
|
||||||
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
|
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
|
||||||
|
|
||||||
- name: Setup Flux CLI
|
- name: Setup Flux CLI
|
||||||
if: inputs.push_manifests == true
|
if: inputs.push_manifests == 'true'
|
||||||
uses: https://github.com/fluxcd/flux2/action@main
|
uses: https://github.com/fluxcd/flux2/action@main
|
||||||
with:
|
with:
|
||||||
version: v2.5.0
|
version: v2.5.0
|
||||||
@@ -77,9 +73,6 @@ jobs:
|
|||||||
files: |
|
files: |
|
||||||
./docker-bake.hcl
|
./docker-bake.hcl
|
||||||
cwd://${{ steps.meta.outputs.bake-file }}
|
cwd://${{ steps.meta.outputs.bake-file }}
|
||||||
set: |
|
|
||||||
*.cache-from=type=gha
|
|
||||||
*.cache-to=type=gha,mode=max
|
|
||||||
push: true
|
push: true
|
||||||
sbom: true
|
sbom: true
|
||||||
provenance: mode=max
|
provenance: mode=max
|
||||||
@@ -88,24 +81,23 @@ jobs:
|
|||||||
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
|
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
|
||||||
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
|
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
|
||||||
|
|
||||||
- name: Generate outputs
|
- name: Output images
|
||||||
|
id: images
|
||||||
run: |
|
run: |
|
||||||
echo ${{ steps.bake.outputs.metadata }} | jq 'map_values((."image.name" | split(",|:";"")).[] + "@" + ."containerimage.digest")' >> $GITHUB_OUTPUT
|
METADATA='${{ steps.bake.outputs.metadata }}'
|
||||||
|
IMAGES=$(echo ${METADATA} | jq 'map_values((."image.name" | select(. != null) | split(",|:";""))[0] + "@" + ."containerimage.digest")')
|
||||||
# TODO: Move this into docker-bake.hcl
|
echo images=${IMAGES} >> $GITHUB_OUTPUT
|
||||||
- name: Generate CRDs
|
|
||||||
if: inputs.generate_crds == true
|
|
||||||
run: |
|
|
||||||
docker run --rm ${{ env.OCI_REPO }}@${{ steps.build.outputs.imageid }} /crdgen > ./manifests/crds.yaml
|
|
||||||
|
|
||||||
- name: Kustomize manifests
|
- name: Kustomize manifests
|
||||||
if: inputs.push_manifests == true
|
if: inputs.push_manifests == 'true'
|
||||||
run: |
|
run: |
|
||||||
# TODO: Fix this
|
curl -L https://github.com/hairyhenderson/gomplate/releases/download/v4.3.3/gomplate_linux-amd64 -o gomplate
|
||||||
./kustomize build ./manifests | sed "s/\${DIGEST}/${{ steps.build.outputs.digest }}/" > ./manifests.yaml
|
chmod +x ./gomplate
|
||||||
|
echo ${{ steps.images.outputs.images }} > ./images.json
|
||||||
|
./kustomize build ./manifests | ./gomplate --context images="file://${PWD}/images.json" > ./manifests.yaml
|
||||||
|
|
||||||
- name: Push manifests
|
- name: Push manifests
|
||||||
if: inputs.push_manifests == true
|
if: inputs.push_manifests == 'true'
|
||||||
run: |
|
run: |
|
||||||
flux push artifact oci://${{ env.OCI_REPO }}/manifests:${{ gitea.head_ref || gitea.ref_name }} \
|
flux push artifact oci://${{ env.OCI_REPO }}/manifests:${{ gitea.head_ref || gitea.ref_name }} \
|
||||||
--path="./manifests.yaml" \
|
--path="./manifests.yaml" \
|
||||||
@@ -114,24 +106,9 @@ jobs:
|
|||||||
$(echo "${{ steps.meta.outputs.labels }}" | sed -e 's/^/-a /')
|
$(echo "${{ steps.meta.outputs.labels }}" | sed -e 's/^/-a /')
|
||||||
|
|
||||||
flux tag artifact oci://${{ env.OCI_REPO }}/manifests:${{ gitea.head_ref || gitea.ref_name }} \
|
flux tag artifact oci://${{ env.OCI_REPO }}/manifests:${{ gitea.head_ref || gitea.ref_name }} \
|
||||||
$(echo "${{ steps.meta.outputs.tags }}" | sed -e 's/^.*:/--tag /')
|
$(echo "${{ steps.meta.outputs.tags }}" | sed -e 's/^/--tag /')
|
||||||
|
|
||||||
- name: Call webhook
|
- name: Call webhook
|
||||||
if: inputs.webhook_url != ''
|
if: inputs.webhook_url != ''
|
||||||
run: |
|
run: |
|
||||||
curl ${{ inputs.webhook_url }}
|
curl ${{ inputs.webhook_url }} || true
|
||||||
|
|
||||||
- name: Notify build status
|
|
||||||
if: failure()
|
|
||||||
uses: appleboy/telegram-action@master
|
|
||||||
with:
|
|
||||||
to: ${{ secrets.TELEGRAM_TO }}
|
|
||||||
token: ${{ secrets.TELEGRAM_TOKEN }}
|
|
||||||
# TODO: Escaping issues need to be solved first
|
|
||||||
# format: markdown
|
|
||||||
message: |
|
|
||||||
🚨 *BUILD FAILED!*
|
|
||||||
${{ gitea.repository }} (#${{ gitea.run_number }})
|
|
||||||
|
|
||||||
[${{ gitea.ref_name }}@sha1:${{ gitea.sha }}]
|
|
||||||
> ${{ gitea.event.head_commit.message }}
|
|
||||||
Reference in New Issue
Block a user