mirror of
https://github.com/Dokploy/templates
synced 2025-06-26 18:16:07 +00:00
refactor: Optimize base64 templates workflow to process only changed blueprints
This commit is contained in:
parent
7e802027a4
commit
6fd5c52d6c
48
.github/workflows/base64-templates.yml
vendored
48
.github/workflows/base64-templates.yml
vendored
@ -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 "<details>" >> comment.md
|
||||
echo "<summary>🔍 Show all blueprints base64</summary>" >> comment.md
|
||||
echo '' >> comment.md
|
||||
if [ -z "$CHANGED_FOLDERS" ]; then
|
||||
echo "✅ No blueprints changed." >> comment.md
|
||||
else
|
||||
echo "<details>" >> comment.md
|
||||
echo "<summary>🔍 Show base64</summary>" >> 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 '</details>' >> comment.md
|
||||
echo '</details>' >> 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
|
||||
|
Loading…
Reference in New Issue
Block a user