Publish Schemas #173
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 * * *" | |
push: | |
branches: ["main"] | |
paths: [".github/workflows/publish-schemas.yaml"] | |
jobs: | |
publish-manifests: | |
name: Publish Manifests | |
runs-on: ["gha-runner-scale-set-home-gitops"] | |
steps: | |
- name: Setup Flux | |
uses: fluxcd/flux2/action@5350425cdcd5fa015337e09fa502153c0275bd4b # v2.4.0 | |
- 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: 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: Setup crd-extractor | |
uses: robinraju/release-downloader@a96f54c1b5f5e09e47d9504526e96febd949d4c2 # v1.11 | |
with: | |
repository: datreeio/CRDs-catalog | |
latest: true | |
fileName: crd-extractor.zip | |
- name: Write kubeconfig | |
id: kubeconfig | |
uses: timheuer/base64-to-file@adaa40c0c581f276132199d4cf60afa07ce60eac # v1.2 | |
with: | |
encodedString: ${{ secrets.KUBECONFIG }} | |
fileName: kubeconfig | |
- name: Run crd-extractor | |
env: | |
KUBECONFIG: ${{ steps.kubeconfig.outputs.filePath }} | |
run: | | |
unzip -j $GITHUB_WORKSPACE/crd-extractor.zip -d $GITHUB_WORKSPACE | |
bash $GITHUB_WORKSPACE/crd-extractor.sh | |
- name: Lowercase Owner Name | |
env: | |
REPO_OWNER: '${{ github.repository_owner }}' | |
run: | | |
echo "REPO_OWNER_LC=${REPO_OWNER,,}" >>${GITHUB_ENV} | |
- name: Generate tag | |
id: generate-tag | |
run: echo "tag=ghcr.io/${REPO_OWNER_LC}/manifests/kubernetes-schemas:$(git rev-parse --short HEAD)" >> "${GITHUB_OUTPUT}" | |
- name: Publish manifests | |
run: | | |
flux push artifact oci://${{ steps.generate-tag.outputs.tag }} \ | |
--path="/home/runner/.datree/crdSchemas" \ | |
--source="${{ github.repositoryUrl }}" \ | |
--revision="${{ github.ref_name }}@sha1:$(git rev-parse HEAD)" | |
- name: Tag manifests | |
run: flux tag artifact oci://${{ steps.generate-tag.outputs.tag }} --tag main | |
publish-web: | |
name: Publish Web | |
runs-on: ubuntu-latest | |
needs: ["publish-manifests"] | |
steps: | |
- name: Setup Flux | |
uses: fluxcd/flux2/action@5350425cdcd5fa015337e09fa502153c0275bd4b # v2.4.0 | |
- 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: 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: Lowercase Owner Name | |
env: | |
REPO_OWNER: '${{ github.repository_owner }}' | |
run: | | |
echo "REPO_OWNER_LC=${REPO_OWNER,,}" >>${GITHUB_ENV} | |
- name: Pull manifests | |
run: | | |
mkdir -p /home/runner/crdSchemas | |
flux pull artifact oci://ghcr.io/${REPO_OWNER_LC}/manifests/kubernetes-schemas:$(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 web container | |
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0 | |
with: | |
context: /home/runner/crdSchemas | |
platforms: linux/amd64,linux/arm64 | |
file: /home/runner/crdSchemas/Dockerfile | |
push: true | |
tags: | | |
ghcr.io/${{ env.REPO_OWNER_LC }}/kubernetes-schemas:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
labels: | | |
org.opencontainers.image.source="${{ github.repositoryUrl }}" | |
org.opencontainers.image.authors="Jeff Davis <[email protected]>" |