Skip to content

test: pr

test: pr #15

Workflow file for this run

name: ArgoCD Diff on PR
on:
pull_request:
paths:
- "k8s-apps/**"
jobs:
argocd-diff:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up environment
run: |
# Install ArgoCD CLI
curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x /usr/local/bin/argocd
- name: Get updated apps
id: updated-apps
run: |
git fetch origin
# Extract unique app names from the modified paths under k8s-apps
MODIFIED_APPS=$(git diff --name-only origin/main...HEAD | grep '^k8s-apps/' | awk -F'/' '{print $2}' | sort -u | xargs)
if [ -z "$MODIFIED_APPS" ]; then
echo "No changes detected"
echo "apps=" >> $GITHUB_OUTPUT
else
echo "Modified apps: $MODIFIED_APPS"
echo "apps=$MODIFIED_APPS" >> $GITHUB_OUTPUT
fi
- name: Login to ArgoCD
if: steps.updated-apps.outputs.apps != ''
run: |
argocd login argocd.terence.cloud --grpc-web --username admin --password $ARGOCD_ADMIN_PASSWORD
env:
ARGOCD_ADMIN_PASSWORD: ${{ secrets.ARGOCD_ADMIN_PASSWORD }}
- name: ArgoCD Diff for updated apps
if: steps.updated-apps.outputs.apps != ''
run: |
for APP in ${{ steps.updated-apps.outputs.apps }}; do
echo "Processing app: $APP"
cd "k8s-apps/$APP"
helm dep update
argocd app diff "$APP" \
--grpc-web \
--local-repo-root $(git rev-parse --show-toplevel) \
--local $PWD \
--loglevel warn \
--diff-exit-code 0
done