test: pr #6
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
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 charts | |
id: updated-charts | |
run: | | |
git fetch origin # Ensure the latest refs are fetched | |
MODIFIED_PATHS=$(git diff --name-only origin/main...HEAD) | |
if [ -z "$MODIFIED_PATHS" ]; then | |
echo "No changes detected" | |
echo "::set-output name=paths::" | |
else | |
echo "Modified paths: $MODIFIED_PATHS" | |
echo "::set-output name=paths::$MODIFIED_PATHS" | |
fi | |
- name: Login to ArgoCD | |
if: steps.updated-charts.outputs.apps != '' | |
run: | | |
argocd login --grpc-web --username admin --password $ARGOCD_ADMIN_PASSWORD argocd.terence.cloud | |
- name: ArgoCD Diff for updated apps | |
if: steps.updated-charts.outputs.apps != '' | |
run: | | |
for APP in ${{ steps.updated-charts.outputs.apps }}; do | |
echo "Processing app: $APP" | |
cd "k8s-apps/$APP" | |
argocd app diff "$APP" \ | |
--grpc-web \ | |
--local-repo-root $(git rev-parse --show-toplevel) \ | |
--local $PWD \ | |
--loglevel warn | |
done | |
env: | |
ARGOCD_ADMIN_PASSWORD: ${{ secrets.ARGOCD_ADMIN_PASSWORD }} |