diff --git a/.github/workflows/base64-templates.yml b/.github/workflows/base64-templates.yml index 80010d10..1bd899f7 100644 --- a/.github/workflows/base64-templates.yml +++ b/.github/workflows/base64-templates.yml @@ -1,12 +1,7 @@ -name: Generate Base64 Blueprints Table - on: pull_request: branches: - main - push: - branches: - - main jobs: encode-and-comment: @@ -16,23 +11,30 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - - name: Generate base64 for blueprints + - name: Get changed blueprint folders + id: changes + run: | + echo "folders=$(git diff --name-only ${{ github.event.pull_request.base.sha }} | grep '^blueprints/' | cut -d/ -f2 | sort -u | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT + + - name: Generate base64 for changed blueprints only id: generate run: | - echo "### 📝 Blueprints Base64 Table" > comment.md + CHANGED_FOLDERS=$(echo '${{ steps.changes.outputs.folders }}' | jq -r '.[]') + + echo "### 📝 Base64 for changed blueprints" > comment.md echo '' >> comment.md - echo "You can use the base64 value to import the blueprint into the UI." >> comment.md - echo "
" >> comment.md - echo "🔍 Show all blueprints base64" >> comment.md - echo '' >> comment.md + if [ -z "$CHANGED_FOLDERS" ]; then + echo "✅ No blueprints changed." >> comment.md + else + echo "
" >> comment.md + echo "🔍 Show base64" >> comment.md + echo '' >> comment.md - for dir in blueprints/*; do - if [ -d "$dir" ]; then - TEMPLATE_NAME=$(basename "$dir") - - COMPOSE_FILE="$dir/docker-compose.yml" - TEMPLATE_FILE="$dir/template.yml" + for dir in $CHANGED_FOLDERS; do + TEMPLATE_NAME="$dir" + COMPOSE_FILE="blueprints/$dir/docker-compose.yml" + TEMPLATE_FILE="blueprints/$dir/template.yml" if [ -f "$COMPOSE_FILE" ] && [ -f "$TEMPLATE_FILE" ]; then COMPOSE_CONTENT=$(jq -Rs . < "$COMPOSE_FILE") @@ -48,19 +50,13 @@ jobs: echo '```' >> comment.md echo '' fi - fi - done + done - echo '
' >> comment.md + echo '
' >> comment.md + fi - name: Post comment to PR uses: marocchino/sticky-pull-request-comment@v2 if: github.event_name == 'pull_request' with: path: comment.md - - - name: Post comment to commit (fallback) - uses: peter-evans/commit-comment@v3 - if: github.event_name != 'pull_request' - with: - body-path: comment.md