Skip to content

Publish Schemas

Publish Schemas #12

---
name: "Publish Schemas"
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 0"
push:
branches: ["main"]
paths: [".github/workflows/publish-schemas.yaml"]
env:
DEBCONF_NONINTERACTIVE_SEEN: "true"
DEBIAN_FRONTEND: noninteractive
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE: DontWarn
jobs:
publish-schemas:
name: Publish Schemas
runs-on: ["arc-runner-set-home-kubernetes"]
permissions:
packages: write
contents: read
steps:
- name: Setup Tools
shell: bash
run: |
sudo apt-get -qq update && \
sudo apt-get -qq install --no-install-recommends -y curl
- name: Setup Kube Tools
uses: yokawasa/action-setup-kube-tools@af4ebb1af1efd30c5bd84a2e9773355ad6362a33 # v0.9.3
with:
setup-tools: kubectl
- name: Setup Python
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: 3.x
- name: Setup QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- name: Generate container metadata
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5.3.0
with:
images: |
ghcr.io/${{ github.repository_owner }}/kubernetes-schemas
tags: |
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Login to GitHub Container Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ghcr.io
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: Write kubeconfig
id: kubeconfig
uses: timheuer/base64-to-file@784a1a4a994315802b7d8e2084e116e783d157be # v1.2.4
with:
encodedString: ${{ secrets.KUBECONFIG }}
fileName: kubeconfig
- name: Download and run crd-extractor
env:
KUBECONFIG: ${{ steps.kubeconfig.outputs.filePath }}
shell: bash
run: |
mkdir -p /home/runner/crds
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
mv /home/runner/.datree/crdSchemas/* /home/runner/crds
- name: Write Dockerfile
shell: bash
run: |
cat <<EOF > Dockerfile
FROM docker.io/nginxinc/nginx-unprivileged:latest
COPY --chown=nginx:nginx --chmod=755 . /usr/share/nginx/html
USER nginx
EOF
- name: Build and publish container
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
context: /home/runner/crds
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: "${{ steps.meta.outputs.tags }}"
labels: "${{ steps.meta.outputs.labels }}"