start managing azure infra with terraform #48
Workflow file for this run
This file contains hidden or 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
| name: Argo CD Diff Preview | |
| on: | |
| pull_request_target: | |
| paths: | |
| - 'kubernetes/**' # All Kubernetes manifests owned by ArgoCD live here | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout the PR | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| path: pull-request | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Checkout out kubernetes/k8s.io main branch | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| ref: main | |
| path: main | |
| - name: Generate Diff | |
| run: | | |
| # Kustomize and Helm don't work by default with argocd-diff, so we need to amend argocd a bit | |
| kind create cluster | |
| helm repo add argo https://argoproj.github.io/argo-helm | |
| helm upgrade --install argocd argo/argo-cd --version 9.3.4 --create-namespace --namespace argocd-diff-preview \ | |
| --set config.params."kustomize\.buildOptions"="--load-restrictor LoadRestrictionsNone --enable-alpha-plugins" | |
| kubectl apply -n argocd-diff-preview -f pull-request/kubernetes/gke-utility/argocd/clusters.yaml || true # ignore errors from missing ES | |
| kubectl apply -n argocd-diff-preview -f pull-request/kubernetes/gke-utility/argocd/clusters-diff.yaml # ES based clusters | |
| docker run \ | |
| --network=host \ | |
| -v ~/.kube:/root/.kube \ | |
| -v /var/run/docker.sock:/var/run/docker.sock \ | |
| -v $(pwd)/main:/base-branch \ | |
| -v $(pwd)/pull-request:/target-branch \ | |
| -v $(pwd)/output:/output \ | |
| -e TARGET_BRANCH=refs/pull/${{ github.event.number }}/merge \ | |
| -e REPO=${{ github.repository }} \ | |
| dagandersen/argocd-diff-preview:v0.1.21 \ | |
| --argocd-namespace=argocd-diff-preview \ | |
| --create-cluster=false | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f #v6.0.0 | |
| with: | |
| name: diff-md | |
| path: output/diff.md | |
| comment: | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 | |
| with: | |
| name: diff-md | |
| path: output | |
| - name: Post diff as comment | |
| env: | |
| GH_TOKEN: ${{ secrets.K8S_INFRA_CI_BOT_PR_TOKEN }} | |
| run: | | |
| gh pr comment ${{ github.event.number }} --repo ${{ github.repository }} --body-file output/diff.md --edit-last --create-if-none |