Skip to content

Instantly share code, notes, and snippets.

@walkure
Created December 11, 2022 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walkure/c6c82d5ed93139e0dc27f55c43cd6b2e to your computer and use it in GitHub Desktop.
Save walkure/c6c82d5ed93139e0dc27f55c43cd6b2e to your computer and use it in GitHub Desktop.
GitHub Action for showing diff of kustomized ArgoCD Application
name: Show kustomized Application diff
on:
pull_request:
paths:
- '**.yaml'
- '**.yml'
jobs:
enumerate:
name: Enumerate ArgoCD Applications
runs-on: ubuntu-latest
outputs:
applications: ${{ steps.jqlist.outputs.result }}
steps:
- uses: actions/checkout@v2
- name: collect applications
id: jqlist
uses: mikefarah/yq@master
with:
cmd: find applications -name '*.yml' -or -name '*.yaml' | xargs yq ea -o=json -N '[.spec.source.path]'
kustomize-diff:
name: Generate kustomized Diff
needs: enumerate
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
applications: ${{ fromJson(needs.enumerate.outputs.applications) }}
steps:
- id: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- id: kustomize-diff
uses: walkure/github-action-kustomize-diff@master
with:
envpath_pattern: ${{matrix.applications}}
- id: comment
if: steps.kustomize-diff.outputs.diff != 'No Difference'
uses: thollander/actions-comment-pull-request@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: ${{ steps.kustomize-diff.outputs.diff }}
comment_tag: kustdiff-${{matrix.applications}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment