-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 changed files
with
235 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 🔥Config Examples | ||
|
||
## Workflows | ||
|
||
The workflows directory contains a set of GitHub actions that you can use to have 🔥Config automatically compute the | ||
mermaid DAG and diff of changes to your Kubernetes objects, and then leave a comment on the PR with the DAG and diff. | ||
You _should_ just be able to copy these into your `.github/workflows` directory. You'll need to set up a personal | ||
access token (PAT) with read access to your actions and read and write access to pull requests. This PAT then needs to | ||
be injected into your actions as a GitHub secret. | ||
|
||
- [Managing your Personal Access Tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) | ||
- [Using secrets in GitHub Actions](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions) |
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,49 @@ | ||
name: Compute k8s plan | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'k8s/**' | ||
|
||
jobs: | ||
plan: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out master | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: master | ||
submodules: recursive | ||
|
||
- name: Install Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
|
||
- name: Compile k8s charts | ||
run: make k8s | ||
|
||
- name: Check out PR | ||
uses: actions/checkout@v4 | ||
with: | ||
clean: false | ||
|
||
- name: Compute dag/diff | ||
run: make k8s | ||
|
||
- name: Save artifacts | ||
run: | | ||
mkdir -p ./artifacts | ||
echo ${{ github.event.number }} > ./artifacts/PR | ||
mv .build/dag.mermaid ./artifacts/dag.mermaid | ||
mv .build/k8s.df ./artifacts/k8s.df | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: k8s-plan-artifacts | ||
path: artifacts/ |
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,58 @@ | ||
name: Comment on the PR | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Compute k8s plan"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
pr-comment: | ||
runs-on: ubuntu-latest | ||
if: > | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: k8s-plan-artifacts | ||
github-token: ${{ secrets.PR_COMMENT_TOKEN }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
path: k8s-plan-artifacts | ||
|
||
- name: Get PR number | ||
uses: mathiasvr/[email protected] | ||
id: pr | ||
with: | ||
run: cat k8s-plan-artifacts/PR | ||
|
||
- name: Find previous comment ID | ||
uses: peter-evans/find-comment@v2 | ||
id: fc | ||
with: | ||
token: ${{ secrets.PR_COMMENT_TOKEN }} | ||
issue-number: ${{ steps.pr.outputs.stdout }} | ||
body-includes: "<!-- 🔥config summary -->" | ||
|
||
- name: Render Comment Template | ||
run: | | ||
echo "<!-- 🔥config summary -->" > fireconfig-comment.md | ||
echo "## Kubernetes Object DAG" >> fireconfig-comment.md | ||
cat k8s-plan-artifacts/dag.mermaid >> fireconfig-comment.md | ||
echo '<img src="https://raw.githubusercontent.com/acrlabs/fireconfig/master/assets/new.png" width=10/> New object' >> fireconfig-comment.md | ||
echo '<img src="https://raw.githubusercontent.com/acrlabs/fireconfig/master/assets/removed.png" width=10/> Deleted object' >> fireconfig-comment.md | ||
echo '<img src="https://raw.githubusercontent.com/acrlabs/fireconfig/master/assets/changed.png" width=10/> Updated object' >> fireconfig-comment.md | ||
echo '<img src="https://raw.githubusercontent.com/acrlabs/fireconfig/master/assets/pod_recreate.png" width=10/> Updated object (causes pod recreation)' >> fireconfig-comment.md | ||
echo "## Detailed Diff" >> fireconfig-comment.md | ||
cat k8s-plan-artifacts/k8s.df >> fireconfig-comment.md | ||
- name: Comment on PR | ||
uses: peter-evans/create-or-update-comment@v3 | ||
with: | ||
token: ${{ secrets.PR_COMMENT_TOKEN }} | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ steps.pr.outputs.stdout }} | ||
body-path: fireconfig-comment.md | ||
edit-mode: replace |
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,44 @@ | ||
name: Update the PR Comment | ||
|
||
on: | ||
####################################################################################### | ||
# WARNING: DO NOT CHANGE THIS ACTION TO CHECK OUT OR EXECUTE ANY CODE!!!!! # | ||
# # | ||
# This can allow an attacker to gain write access to code in the repository or read # | ||
# any repository secrets! This should _only_ be used to update or add a PR comment. # | ||
# # | ||
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ # | ||
# for more details. # | ||
####################################################################################### | ||
pull_request_target: | ||
paths: | ||
- 'k8s/**' | ||
|
||
jobs: | ||
pr-comment: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Find previous comment ID | ||
uses: peter-evans/find-comment@v3 | ||
id: fc | ||
with: | ||
token: ${{ secrets.PR_COMMENT_TOKEN }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body-includes: "<!-- 🔥config summary -->" | ||
|
||
- name: Render Comment Template | ||
run: | | ||
echo | ||
- name: Comment on PR | ||
uses: peter-evans/create-or-update-comment@v3 | ||
with: | ||
token: ${{ secrets.PR_COMMENT_TOKEN }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
body: | | ||
<!-- 🔥config summary --> | ||
## Updating Kubernetes DAG... | ||
Please wait until the job has finished. | ||
edit-mode: replace |
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 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