-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
123 additions
and
125 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,33 +1,29 @@ | ||
--- | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
name: "Terraform: Build OCI artifacts" | ||
|
||
on: # yamllint disable-line rule:truthy | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "infrastructure/terraform/**" | ||
- .github/workflows/build-terraform-oci.yaml | ||
- infrastructure/terraform/** | ||
|
||
jobs: | ||
changed-files: | ||
name: Generate matrix for building images | ||
runs-on: ubuntu-22.04 | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Nix | ||
uses: cachix/install-nix-action@v24 | ||
with: | ||
github_access_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Switch to Nix devShell | ||
uses: nicknovitski/[email protected] | ||
with: | ||
arguments: "./.ci" | ||
- name: Install System Tools | ||
shell: bash | ||
run: sudo apt-get -qq update && sudo apt-get -qq install --no-install-recommends -y jo | ||
|
||
- name: Get changed files | ||
id: changed-files | ||
|
@@ -53,21 +49,31 @@ jobs: | |
fi | ||
publish: | ||
runs-on: ubuntu-22.04 | ||
runs-on: ubuntu-latest | ||
needs: | ||
- changed-files | ||
strategy: | ||
matrix: ${{ fromJSON(needs.changed-files.outputs.matrix) }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
- name: Generate Token | ||
uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: ${{ secrets.BJWS_APP_ID }} | ||
private-key: ${{ secrets.BJWS_APP_PRIVATE_KEY }} | ||
|
||
- name: Set up Homebrew | ||
uses: Homebrew/actions/setup-homebrew@master | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ steps.app-token.outputs.token }} | ||
|
||
- name: Setup Tools | ||
run: | | ||
brew install fluxcd/tap/flux | ||
- uses: jdx/rtx-action@v1 | ||
with: | ||
install: true | ||
cache: true | ||
rtx_toml: | | ||
[tools] | ||
flux2 = "latest" | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
|
@@ -76,14 +82,18 @@ jobs: | |
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Generate tag | ||
id: generate-tag | ||
shell: bash | ||
run: echo "tag=ghcr.io/${{ github.repository_owner }}/terraform/$(basename ${{ matrix.project }}):$(git rev-parse --short HEAD)" >> "${GITHUB_OUTPUT}" | ||
|
||
- name: Publish OCI | ||
run: | | ||
flux push artifact "oci://ghcr.io/bjw-s/terraform/$(basename ${{ matrix.project }}):$(git rev-parse --short HEAD)" \ | ||
flux push artifact "oci://${{ steps.generate-tag.outputs.tag }}" \ | ||
--path="./${{ matrix.project }}" \ | ||
--source="$(git config --get remote.origin.url)" \ | ||
--revision="$(git branch --show-current)/$(git rev-parse HEAD)" | ||
- name: Tag OCI | ||
run: | | ||
flux tag artifact "oci://ghcr.io/bjw-s/terraform/$(basename ${{ matrix.project }}):$(git rev-parse --short HEAD)" \ | ||
--tag main | ||
flux tag artifact "oci://${{ steps.generate-tag.outputs.tag }}" --tag main |
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,4 +1,5 @@ | ||
--- | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
name: "Flux Diff" | ||
|
||
on: | ||
|
@@ -7,20 +8,53 @@ on: | |
- main | ||
paths: | ||
- .github/workflows/flux-diff.yaml | ||
- kubernetes/**.yaml | ||
- kubernetes/** | ||
|
||
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.BJWS_APP_ID }} | ||
private-key: ${{ secrets.BJWS_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/main | ||
- kubernetes/nas | ||
resource: | ||
paths: ${{ fromJSON(needs.changed-files.outputs.matrix) }} | ||
resources: | ||
- helmrelease | ||
- kustomization | ||
steps: | ||
|
@@ -31,22 +65,45 @@ jobs: | |
app-id: ${{ secrets.BJWS_APP_ID }} | ||
private-key: ${{ secrets.BJWS_APP_PRIVATE_KEY }} | ||
|
||
- uses: jdx/rtx-action@v1 | ||
with: | ||
install: true | ||
cache: true | ||
rtx_toml: | | ||
[tools] | ||
flux2 = "latest" | ||
- name: Diff Resources | ||
uses: allenporter/flux-local/action/[email protected] | ||
id: diff | ||
with: | ||
sources: home-ops-kubernetes | ||
path: "${{ matrix.path }}" | ||
resource: "${{ matrix.resource }}" | ||
path: "${{ matrix.paths }}" | ||
resource: "${{ matrix.resources }}" | ||
|
||
- if: ${{ steps.diff.outputs.diff != '' }} | ||
name: Add comment | ||
uses: mshick/[email protected] | ||
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 }} | ||
``` | ||
flux-diff-success: | ||
needs: | ||
- flux-diff | ||
if: ${{ always() }} | ||
name: Flux Diff successful | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check matrix status | ||
if: >- | ||
${{ | ||
contains(needs.*.result, 'failure') | ||
|| contains(needs.*.result, 'cancelled') | ||
}} | ||
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
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 |
---|---|---|
|
@@ -36,20 +36,13 @@ jobs: | |
with: | ||
token: "${{ steps.app-token.outputs.token }}" | ||
|
||
- name: Install OS Deps | ||
shell: bash | ||
run: | | ||
sudo apt-get update && sudo apt-get install -y curl git xz-utils | ||
- name: Install Nix | ||
uses: cachix/install-nix-action@v24 | ||
with: | ||
github_access_token: "${{ steps.app-token.outputs.token }}" | ||
|
||
- name: Switch to Nix devShell | ||
uses: nicknovitski/[email protected] | ||
- uses: jdx/rtx-action@v1 | ||
with: | ||
arguments: "./.ci" | ||
install: true | ||
cache: true | ||
rtx_toml: | | ||
[tools] | ||
flux2 = "latest" | ||
- name: Write kubeconfig | ||
id: kubeconfig | ||
|
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.