Publish Schemas #120
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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-ops"] | |
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@9e25a4277af127b60011c95b6ed2da7e3b3613b1 # v0.11.2 | |
with: | |
setup-tools: kubectl | |
- name: Setup Python | |
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 | |
with: | |
python-version: 3.x | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 | |
- name: Setup Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0 | |
- name: Generate container metadata | |
id: meta | |
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1 | |
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@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.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@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.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 }}" |