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:
48
.github/workflows/base64-templates.yml
vendored
48
.github/workflows/base64-templates.yml
vendored
@@ -1,12 +1,7 @@
|
|||||||
name: Generate Base64 Blueprints Table
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
encode-and-comment:
|
encode-and-comment:
|
||||||
@@ -16,23 +11,30 @@ jobs:
|
|||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v4
|
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
|
id: generate
|
||||||
run: |
|
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 '' >> comment.md
|
||||||
|
|
||||||
echo "You can use the base64 value to import the blueprint into the UI." >> comment.md
|
if [ -z "$CHANGED_FOLDERS" ]; then
|
||||||
echo "<details>" >> comment.md
|
echo "✅ No blueprints changed." >> comment.md
|
||||||
echo "<summary>🔍 Show all blueprints base64</summary>" >> comment.md
|
else
|
||||||
echo '' >> comment.md
|
echo "<details>" >> comment.md
|
||||||
|
echo "<summary>🔍 Show base64</summary>" >> comment.md
|
||||||
|
echo '' >> comment.md
|
||||||
|
|
||||||
for dir in blueprints/*; do
|
for dir in $CHANGED_FOLDERS; do
|
||||||
if [ -d "$dir" ]; then
|
TEMPLATE_NAME="$dir"
|
||||||
TEMPLATE_NAME=$(basename "$dir")
|
COMPOSE_FILE="blueprints/$dir/docker-compose.yml"
|
||||||
|
TEMPLATE_FILE="blueprints/$dir/template.yml"
|
||||||
COMPOSE_FILE="$dir/docker-compose.yml"
|
|
||||||
TEMPLATE_FILE="$dir/template.yml"
|
|
||||||
|
|
||||||
if [ -f "$COMPOSE_FILE" ] && [ -f "$TEMPLATE_FILE" ]; then
|
if [ -f "$COMPOSE_FILE" ] && [ -f "$TEMPLATE_FILE" ]; then
|
||||||
COMPOSE_CONTENT=$(jq -Rs . < "$COMPOSE_FILE")
|
COMPOSE_CONTENT=$(jq -Rs . < "$COMPOSE_FILE")
|
||||||
@@ -48,19 +50,13 @@ jobs:
|
|||||||
echo '```' >> comment.md
|
echo '```' >> comment.md
|
||||||
echo ''
|
echo ''
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
done
|
|
||||||
|
|
||||||
echo '</details>' >> comment.md
|
echo '</details>' >> comment.md
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Post comment to PR
|
- name: Post comment to PR
|
||||||
uses: marocchino/sticky-pull-request-comment@v2
|
uses: marocchino/sticky-pull-request-comment@v2
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
with:
|
with:
|
||||||
path: comment.md
|
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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user