Skip to content

Commit

Permalink
feat(arc): switch to nixpkg in github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
buroa committed Dec 17, 2023
1 parent 047aaad commit 38252d5
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 77 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/flux-diff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ on:
branches: ["master"]
paths: ["kubernetes/**.yaml"]

env:
DEBCONF_NONINTERACTIVE_SEEN: "true"
DEBIAN_FRONTEND: noninteractive
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE: DontWarn
NIX_FLAKE_PATH: ./.github/workflows/resources/nix

jobs:
flux-diff:
name: Flux Diff
Expand All @@ -31,12 +37,8 @@ jobs:
username: "${{ secrets.BOT_APP_ID }}"
password: "${{ steps.app-token.outputs.token }}"

- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Setup Tools
shell: bash
run: brew install fluxcd/tap/flux
- name: Setup Flux
uses: fluxcd/flux2/action@53ad742e2d0f6f0df19ec11a25a0e3adce80c475 # v2.2.0

- name: Diff Resources
# uses: allenporter/flux-local/action/diff@19bfc6920e8964a479363bc230e6c329120ead02 # 3.2.0
Expand Down
52 changes: 31 additions & 21 deletions .github/workflows/flux-hr-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ name: Flux HelmRepository Sync
on:
workflow_dispatch:
inputs:
repoName:
description: Flux HelmRepository Name
required: true
repoNamespace:
description: Flux HelmRepository Namespace
helmRepoNamespace:
description: Helm Repository Namespace
default: flux-system
required: true
helmRepoName:
description: Helm Repository Name
required: true
pull_request:
branches: ["master"]
paths: ["kubernetes/**/helmrelease.yaml"]
Expand All @@ -19,6 +19,7 @@ env:
DEBCONF_NONINTERACTIVE_SEEN: "true"
DEBIAN_FRONTEND: noninteractive
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE: DontWarn
NIX_FLAKE_PATH: ./.github/workflows/resources/nix

jobs:
sync:
Expand All @@ -30,12 +31,17 @@ jobs:
with:
fetch-depth: 0

- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Setup Tools
shell: bash
run: brew install fluxcd/tap/flux yq
run: sudo apt-get -qq update && sudo apt-get -qq install --no-install-recommends -y curl git

- name: Setup Kube Tools
uses: yokawasa/action-setup-kube-tools@af4ebb1af1efd30c5bd84a2e9773355ad6362a33 # v0.9.3
with:
setup-tools: yq

- name: Setup Flux
uses: fluxcd/flux2/action@53ad742e2d0f6f0df19ec11a25a0e3adce80c475 # v2.2.0

- name: Write kubeconfig
id: kubeconfig
Expand All @@ -44,35 +50,39 @@ jobs:
encodedString: "${{ secrets.KUBECONFIG }}"
fileName: kubeconfig

- if: ${{ github.event.inputs.repoNamespace == '' && github.event.inputs.repoName == '' }}
- if: ${{ github.event.inputs.helmRepoNamespace == '' && github.event.inputs.helmRepoName == '' }}
name: Get changed files
id: changed-files
uses: tj-actions/changed-files@94549999469dbfa032becf298d95c87a14c34394 # v40.2.2
with:
files: kubernetes/**/helmrelease.yaml

- if: ${{ github.event.inputs.repoNamespace == '' && github.event.inputs.repoName == '' }}
- if: ${{ github.event.inputs.helmRepoNamespace == '' && github.event.inputs.helmRepoName == '' }}
name: Sync HelmRepository
env:
KUBECONFIG: "${{ steps.kubeconfig.outputs.filePath }}"
shell: bash
run: |
declare -a repos=()
for file in ${{ steps.changed-files.outputs.all_changed_and_modified_files }}; do
repoName="$(yq eval '.spec.chart.spec.sourceRef.name' "${file}")"
repoNamespace="$(yq eval '.spec.chart.spec.sourceRef.namespace' "${file}")"
repos+=("${repoName}:${repoNamespace}")
for f in ${{ steps.changed-files.outputs.all_changed_and_modified_files }}; do
repo_namespace="$(yq '.spec.chart.spec.sourceRef.namespace' "${f}" | xargs)"
repo_name="$(yq '.spec.chart.spec.sourceRef.name' "${f}" | xargs)"
repos+=("${repo_namespace}:${repo_name}")
done
repos=($(for r in ${repos[@]}; do echo $r; done | sort -u))
for repo in ${repos[@]}; do
flux --namespace "${repo##*:}" reconcile source helm "${repo%%:*}"
mapfile -t repos < <(printf "%s\n" "${repos[@]}" | sort -u)
for r in "${repos[@]}"; do
IFS=':' read -r repo_namespace repo_name <<< "${r}"
flux \
--namespace "${repo_namespace}" \
reconcile source helm "${repo_name}"
done
- if: ${{ github.event.inputs.repoNamespace != '' && github.event.inputs.repoName != '' }}
- if: ${{ github.event.inputs.helmRepoNamespace != '' && github.event.inputs.helmRepoName != '' }}
name: Sync HelmRepository
env:
KUBECONFIG: ${{ steps.kubeconfig.outputs.filePath }}
shell: bash
run: |
flux --namespace ${{ github.event.inputs.repoNamespace }} reconcile \
source helm ${{ github.event.inputs.repoName }}
flux \
--namespace "${{ github.event.inputs.helmRepoNamespace }}" \
reconcile source helm "${{ github.event.inputs.helmRepoName }}"
47 changes: 0 additions & 47 deletions .github/workflows/flux-ks-sync.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Meta Sync Labels
name: Label Sync

on:
workflow_dispatch:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Meta Labeler
name: Labeler

on:
workflow_dispatch:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
spec:
containers:
- name: runner
image: ghcr.io/onedr0p/actions-runner:2.311.0@sha256:b29062788e3eaedf38a6bf392ab76dd4b559562358f28dac64e97d7fb605f625
image: ghcr.io/actions/actions-runner:2.311.0@sha256:e505724e0dbb070454912b159645932f74dda9aed03c48c463f33e270a6cbfa1
command:
- /home/runner/run.sh
controllerServiceAccount:
Expand Down

0 comments on commit 38252d5

Please sign in to comment.