Skip to content

feat(github-action): update docker/build-push-action ( v6.10.0 → v6.1… #222

feat(github-action): update docker/build-push-action ( v6.10.0 → v6.1…

feat(github-action): update docker/build-push-action ( v6.10.0 → v6.1… #222

Workflow file for this run

---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: "Publish Kubernetes Schemas"
on:
# Allows manually triggering the workflow from the Github Actions UI
workflow_dispatch: {}
# Runs the workflow weekly at midnight (UTC)
schedule:
- cron: "0 0 * * 0"
push:
branches:
- "main"
paths:
- ".github/workflows/schemas.yaml"
env:
OCI_REPO: "oci://ghcr.io/szinn/kubernetes-schemas/${{ github.event.repository.name }}"
jobs:
publish-kubernetes-schemas:
name: Publish Kubernetes Schemas
runs-on: ["k8s-homelab"]
permissions:
contents: read
packages: write
steps:
- name: Setup Tools
shell: bash
run: |
sudo apt-get -qq update && \
sudo apt-get -qq install --no-install-recommends -y curl unzip git
- name: Setup Flux CLI
uses: fluxcd/flux2/action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Kube Tools
uses: yokawasa/action-setup-kube-tools@9e25a4277af127b60011c95b6ed2da7e3b3613b1 # v0.11.2
with:
setup-tools: kubectl
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: "3.11"
- name: Write kubeconfig
id: kubeconfig
uses: timheuer/base64-to-file@adaa40c0c581f276132199d4cf60afa07ce60eac # v1.2
with:
encodedString: ${{ secrets.KUBECONFIG }}
fileName: kubeconfig
- name: Generate Token
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1
id: app-token
with:
app-id: "${{ secrets.BOT_APP_ID }}"
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
token: "${{ steps.app-token.outputs.token }}"
- name: Download and run crd-extractor
env:
KUBECONFIG: "${{ steps.kubeconfig.outputs.filePath }}"
shell: bash
run: |
curl -fsSL -o "${GITHUB_WORKSPACE}/crd-extractor.sh" \
https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/Utilities/crd-extractor.sh
chmod +x "${GITHUB_WORKSPACE}/crd-extractor.sh"
bash "${GITHUB_WORKSPACE}/crd-extractor.sh"
- name: Login to GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish schemas as OCI
run: |
flux push artifact "${OCI_REPO}:$(git rev-parse --short HEAD)" \
--path="/home/runner/.datree/crdSchemas" \
--source="${{ github.repositoryUrl }}" \
--revision="main"
publish-kubernetes-schemas-web:
runs-on: ubuntu-latest
needs: ["publish-kubernetes-schemas"]
steps:
- name: Generate Token
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1
id: app-token
with:
app-id: "${{ secrets.BOT_APP_ID }}"
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
token: "${{ steps.app-token.outputs.token }}"
- name: Setup Flux CLI
uses: fluxcd/flux2/action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup QEMU
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
- name: Login to GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull schemas as OCI
run: |
mkdir -p /home/runner/crdSchemas
flux pull artifact "${OCI_REPO}:$(git rev-parse --short HEAD)" --output /home/runner/crdSchemas
- name: Write nginx-unprivileged Dockerfile
run: |
cat <<EOF > /home/runner/crdSchemas/Dockerfile
FROM docker.io/nginxinc/nginx-unprivileged:latest
COPY --chown=nginx:nginx --chmod=755 . /usr/share/nginx/html
USER nginx
EOF
- name: Publish schemas as web container
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0
with:
context: /home/runner/crdSchemas
platforms: linux/amd64,linux/arm64
file: /home/runner/crdSchemas/Dockerfile
push: true
tags: |
ghcr.io/szinn/kubernetes-schemas-web:latest
cache-from: type=gha
cache-to: type=gha,mode=max
labels: |
org.opencontainers.image.source="${{ github.repositoryUrl }}"
org.opencontainers.image.authors="Scotte Zinn <[email protected]>"