generated from onedr0p/cluster-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into renovate/sol-k3s-io-k3s-1.x
- Loading branch information
Showing
85 changed files
with
402 additions
and
356 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,129 @@ | ||
--- | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
name: "Flux Diff" | ||
|
||
on: | ||
pull_request: | ||
branches: ["main"] | ||
paths: ["kubernetes/**.yaml"] | ||
paths: ["kubernetes/**"] | ||
|
||
env: | ||
DEBCONF_NONINTERACTIVE_SEEN: "true" | ||
DEBIAN_FRONTEND: noninteractive | ||
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE: DontWarn | ||
NIX_FLAKE_PATH: ./.github/workflows/resources/nix | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
changed-files: | ||
name: Get Changed Files | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.changed-files.outputs.all_changed_and_modified_files }} | ||
steps: | ||
- name: Generate Token | ||
uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: "${{ secrets.BOT_APP_ID }}" | ||
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
token: "${{ steps.app-token.outputs.token }}" | ||
fetch-depth: 0 | ||
|
||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v40 | ||
with: | ||
files: kubernetes/** | ||
dir_names: true | ||
dir_names_max_depth: 2 | ||
json: true | ||
quotepath: false | ||
escape_json: false | ||
|
||
- name: List all changed files | ||
run: echo "${{ steps.changed-files.outputs.all_changed_and_modified_files }}" | ||
|
||
flux-diff: | ||
name: Flux Diff | ||
runs-on: ubuntu-latest | ||
needs: ["changed-files"] | ||
permissions: | ||
pull-requests: write | ||
strategy: | ||
matrix: | ||
path: ["kubernetes/kyak", "kubernetes/sol"] | ||
resource: ["helmrelease", "kustomization"] | ||
paths: ${{ fromJSON(needs.changed-files.outputs.matrix) }} | ||
resources: ["helmrelease", "kustomization"] | ||
max-parallel: 4 | ||
fail-fast: false | ||
steps: | ||
- name: Generate Token | ||
uses: actions/create-github-app-token@2986852ad836768dfea7781f31828eb3e17990fa # v1.6.2 | ||
uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: "${{ secrets.BOT_APP_ID }}" | ||
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" | ||
|
||
- name: Checkout | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
token: "${{ steps.app-token.outputs.token }}" | ||
|
||
- name: Install OS Deps | ||
- name: Setup System Tools | ||
shell: bash | ||
run: sudo apt-get update && sudo apt-get install -y curl git xz-utils | ||
run: sudo apt-get -qq update && sudo apt-get -qq install --no-install-recommends -y curl git | ||
|
||
- name: Install Nix | ||
uses: cachix/install-nix-action@7ac1ec25491415c381d9b62f0657c7a028df52a7 # v24 | ||
- name: Checkout Live Branch | ||
uses: actions/checkout@v4 | ||
with: | ||
github_access_token: "${{ steps.app-token.outputs.token }}" | ||
token: "${{ steps.app-token.outputs.token }}" | ||
ref: main | ||
path: default | ||
|
||
- name: Switch to Nix devShell | ||
uses: nicknovitski/nix-develop@a2060d116a50b36dfab02280af558e73ab52427d # v1.1.0 | ||
- name: Checkout PR branch | ||
uses: actions/checkout@v4 | ||
with: | ||
arguments: "${{ env.NIX_FLAKE_PATH }}" | ||
token: "${{ steps.app-token.outputs.token }}" | ||
path: pull | ||
|
||
- name: Diff Resources | ||
# uses: allenporter/flux-local/action/diff@19bfc6920e8964a479363bc230e6c329120ead02 # 3.2.0 | ||
uses: allenporter/flux-local/action/diff@flux-build | ||
id: diff | ||
uses: docker://ghcr.io/allenporter/flux-local:v4.2.0 | ||
with: | ||
sources: home-kubernetes | ||
path: "${{ matrix.path }}" | ||
resource: "${{ matrix.resource }}" | ||
args: >- | ||
--log-level DEBUG | ||
diff ${{ matrix.resources }} | ||
--unified 6 | ||
--path-orig /github/workspace/default/${{ matrix.paths }} | ||
--path /github/workspace/pull/${{ matrix.paths }} | ||
--strip-attrs "helm.sh/chart,checksum/config,app.kubernetes.io/version,chart" | ||
--limit-bytes 10000 | ||
--all-namespaces | ||
--sources "home-kubernetes" | ||
--output-file diff.patch | ||
- name: Generate Diff | ||
id: diff | ||
run: | | ||
cat diff.patch | ||
echo "diff<<EOF" >> $GITHUB_OUTPUT | ||
cat diff.patch >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
- if: ${{ steps.diff.outputs.diff != '' }} | ||
name: Add comment | ||
uses: mshick/add-pr-comment@7c0890544fb33b0bdd2e59467fbacb62e028a096 # v2.8.1 | ||
uses: mshick/add-pr-comment@v2.8.1 | ||
with: | ||
repo-token: "${{ steps.app-token.outputs.token }}" | ||
message-id: "${{ github.event.pull_request.number }}/${{ matrix.path }}/${{ matrix.resource }}" | ||
message-id: "${{ github.event.pull_request.number }}/${{ matrix.paths }}/${{ matrix.resources }}" | ||
message-failure: Diff was not successful | ||
message: | | ||
```diff | ||
${{ steps.diff.outputs.diff }} | ||
``` | ||
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7 | ||
flux-diff-success: | ||
if: ${{ always() }} | ||
needs: ["flux-diff"] | ||
name: Flux diff successful | ||
runs-on: ubuntu-latest | ||
steps: | ||
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} | ||
name: Check matrix status | ||
run: exit 1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
--- | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
name: "Flux Helm Release Image Test" | ||
|
||
on: | ||
pull_request: | ||
branches: ["main"] | ||
paths: ["kubernetes/**/helmrelease.yaml"] | ||
|
||
env: | ||
WORKFLOW_KUBERNETES_DIR: ./kubernetes | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
changed-files: | ||
name: Get Changed Files | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.changed-files.outputs.all_changed_and_modified_files }} | ||
steps: | ||
- name: Generate Token | ||
uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: "${{ secrets.BOT_APP_ID }}" | ||
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
token: "${{ steps.app-token.outputs.token }}" | ||
fetch-depth: 0 | ||
|
||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v40 | ||
with: | ||
files: kubernetes/**/helmrelease.yaml | ||
json: true | ||
quotepath: false | ||
escape_json: false | ||
|
||
- name: List all changed files | ||
run: echo "${{ steps.changed-files.outputs.all_changed_and_modified_files }}" | ||
|
||
extract-images: | ||
if: ${{ needs.changed-files.outputs.matrix != '[]' }} | ||
name: Extract images from Helm Release | ||
runs-on: ubuntu-latest | ||
needs: ["changed-files"] | ||
strategy: | ||
matrix: | ||
files: ${{ fromJSON(needs.changed-files.outputs.matrix) }} | ||
max-parallel: 4 | ||
fail-fast: false | ||
outputs: | ||
matrix: ${{ steps.extract-images.outputs.images }} | ||
steps: | ||
- name: Generate Token | ||
uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: "${{ secrets.BOT_APP_ID }}" | ||
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
token: "${{ steps.app-token.outputs.token }}" | ||
fetch-depth: 0 | ||
|
||
- name: Setup System Tools | ||
shell: bash | ||
run: sudo apt-get -qq update && sudo apt-get -qq install --no-install-recommends -y curl git | ||
|
||
- name: Setup Workflow Tools | ||
uses: jdx/rtx-action@v1 | ||
with: | ||
install: true | ||
cache: true | ||
rtx_toml: | | ||
[tools] | ||
helm = "latest" | ||
kustomize = "latest" | ||
- name: Extract Images from Helm Release | ||
id: extract-images | ||
run: | | ||
images=$(npx zx ./.github/scripts/extract-images.mjs --kubernetes-dir "${{ env.WORKFLOW_KUBERNETES_DIR }}" --helmrelease "${{ matrix.files }}") | ||
echo "images=${images}" >> $GITHUB_OUTPUT | ||
echo "${images}" | ||
test-images: | ||
if: ${{ needs.extract-images.outputs.matrix != '[]' }} | ||
name: Test images from Helm Release | ||
runs-on: ubuntu-latest | ||
needs: ["extract-images"] | ||
strategy: | ||
matrix: | ||
images: ${{ fromJSON(needs.extract-images.outputs.matrix) }} | ||
max-parallel: 4 | ||
fail-fast: false | ||
steps: | ||
- name: Test Images from Helm Release | ||
run: docker pull ${{ matrix.images }} | ||
|
||
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7 | ||
test-images-success: | ||
if: ${{ always() }} | ||
needs: ["test-images"] | ||
name: Test images from Helm Release successful | ||
runs-on: ubuntu-latest | ||
steps: | ||
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} | ||
name: Check matrix status | ||
run: exit 1 |
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
Oops, something went wrong.