Skip to content

Commit

Permalink
feat(github): testing out aqua workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
buroa committed Dec 20, 2023
1 parent 9a76c2a commit 2f4a5f5
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 26 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/flux-diff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,27 @@ jobs:
app-id: "${{ secrets.BOT_APP_ID }}"
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"

- name: Cache Aqua
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
id: cache
with:
path: ~/.local/share/aquaproj-aqua
key: ${{ runner.os }}-${{ hashFiles('./.github/workflows/resources/aqua.yaml') }}

- if: ${{ steps.cache.outputs.cache-hit != 'true' }}
name: Install Aqua and CLI Tools
uses: aquaproj/aqua-installer@928a2ee4243a9ee8312d80dc8cbaca88fb602a91 # v2.2.0
env:
GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}"

- name: Login to GitHub Container Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ghcr.io
username: "${{ secrets.BOT_APP_ID }}"
password: "${{ steps.app-token.outputs.token }}"

- name: Setup Flux
uses: fluxcd/flux2/action@5c5c15ea212b8f029a110f9975851d25c8272695 # v2.2.2

- name: Diff Resources
# uses: allenporter/flux-local/action/diff@19bfc6920e8964a479363bc230e6c329120ead02 # 3.2.0
uses: allenporter/flux-local/action/diff@flux-build
id: diff
with:
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/flux-hr-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@ jobs:
token: "${{ steps.app-token.outputs.token }}"
fetch-depth: 0

- name: Setup Tools
shell: bash
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
- name: Cache Aqua
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
id: cache
with:
setup-tools: yq
path: ~/.local/share/aquaproj-aqua
key: ${{ runner.os }}-${{ hashFiles('./.github/workflows/resources/aqua.yaml') }}

- name: Setup Flux
uses: fluxcd/flux2/action@5c5c15ea212b8f029a110f9975851d25c8272695 # v2.2.2
- if: ${{ steps.cache.outputs.cache-hit != 'true' }}
name: Install Aqua and CLI Tools
uses: aquaproj/aqua-installer@928a2ee4243a9ee8312d80dc8cbaca88fb602a91 # v2.2.0
env:
GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}"

- name: Write kubeconfig
id: kubeconfig
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/flux-hr-test-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,18 @@ jobs:
token: "${{ steps.app-token.outputs.token }}"
fetch-depth: 0

- name: Setup Kube Tools
uses: yokawasa/action-setup-kube-tools@af4ebb1af1efd30c5bd84a2e9773355ad6362a33 # v0.9.3
- name: Cache Aqua
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
id: cache
with:
setup-tools: helm kustomize
path: ~/.local/share/aquaproj-aqua
key: ${{ runner.os }}-${{ hashFiles('./.github/workflows/resources/aqua.yaml') }}

- if: ${{ steps.cache.outputs.cache-hit != 'true' }}
name: Install Aqua and CLI Tools
uses: aquaproj/aqua-installer@928a2ee4243a9ee8312d80dc8cbaca88fb602a91 # v2.2.0
env:
GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}"

- name: Extract Images from HelmRelease
id: extract-images
Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/publish-terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ jobs:
with:
token: "${{ steps.app-token.outputs.token }}"

- name: Generate tag
id: generate-tag
shell: bash
run: echo "tag=ghcr.io/${{ github.repository_owner }}/manifests/terraform:$(git rev-parse --short HEAD)" >> "${GITHUB_OUTPUT}"

- name: Cache Aqua
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
id: cache
with:
path: ~/.local/share/aquaproj-aqua
key: ${{ runner.os }}-${{ hashFiles('./.github/workflows/resources/aqua.yaml') }}

- if: ${{ steps.cache.outputs.cache-hit != 'true' }}
name: Install Aqua and CLI Tools
uses: aquaproj/aqua-installer@928a2ee4243a9ee8312d80dc8cbaca88fb602a91 # v2.2.0
env:
GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}"

- name: Login to GitHub Container Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
Expand All @@ -37,14 +55,6 @@ jobs:
# username: "${{ secrets.BOT_APP_ID }}"
# password: "${{ steps.app-token.outputs.token }}"

- name: Setup Flux
uses: fluxcd/flux2/action@5c5c15ea212b8f029a110f9975851d25c8272695 # v2.2.2

- name: Generate tag
id: generate-tag
shell: bash
run: echo "tag=ghcr.io/${{ github.repository_owner }}/manifests/terraform:$(git rev-parse --short HEAD)" >> "${GITHUB_OUTPUT}"

- name: Publish manifests
shell: bash
run: |
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/resources/aqua.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
registries:
- type: standard
ref: v4.107.0

packages:
- name: fluxcd/[email protected]
- name: helm/[email protected]
- name: kubernetes-sigs/kustomize@kustomize/v5.3.0
- name: kubernetes/[email protected]
- name: mikefarah/[email protected]
4 changes: 2 additions & 2 deletions .github/workflows/resources/extract-images.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ async function helmTemplate(release, repository) {
// Template out helm values into Kubernetes manifests
let manifests
if ('type' in repository.spec && repository.spec.type == 'oci') {
manifests = await $`${helm} template --kube-version 1.28.0 --release-name ${release.metadata.name} --include-crds=false ${repository.spec.url}/${release.spec.chart.spec.chart} --version ${release.spec.chart.spec.version} --values ${valuesFile.stdout.trim()}`
manifests = await $`${helm} template --kube-version 1.28.0 --release-name ${release.metadata.name} --include-crds=false --skip-tests ${repository.spec.url}/${release.spec.chart.spec.chart} --version ${release.spec.chart.spec.version} --values ${valuesFile.stdout.trim()}`
} else {
await $`${helm} repo add ${release.spec.chart.spec.sourceRef.name} ${repository.spec.url}`
manifests = await $`${helm} template --kube-version 1.28.0 --release-name ${release.metadata.name} --include-crds=false ${release.spec.chart.spec.sourceRef.name}/${release.spec.chart.spec.chart} --version ${release.spec.chart.spec.version} --values ${valuesFile.stdout.trim()}`
manifests = await $`${helm} template --kube-version 1.28.0 --release-name ${release.metadata.name} --include-crds=false --skip-tests ${release.spec.chart.spec.sourceRef.name}/${release.spec.chart.spec.chart} --version ${release.spec.chart.spec.version} --values ${valuesFile.stdout.trim()}`
}

let documents = YAML.parseAllDocuments(manifests.stdout.trim()).map((item) => item.toJS())
Expand Down

0 comments on commit 2f4a5f5

Please sign in to comment.