mirror of
https://github.com/Dokploy/templates
synced 2025-06-26 18:16:07 +00:00
refactor: Modify base64 templates workflow to generate comprehensive blueprint table
This commit is contained in:
56
.github/workflows/base64-templates.yml
vendored
56
.github/workflows/base64-templates.yml
vendored
@@ -1,43 +1,38 @@
|
|||||||
name: Generate Base64 for Changed Blueprints
|
name: Generate Base64 Blueprints Table
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
encode-changed:
|
encode-and-comment:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Get changed blueprints folders
|
- name: Generate base64 for blueprints
|
||||||
id: changes
|
id: generate
|
||||||
run: |
|
run: |
|
||||||
CHANGED=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }} | grep '^blueprints/' | cut -d/ -f2 | sort -u)
|
echo "### 📝 Blueprints Base64 Table" > comment.md
|
||||||
echo "folders=$(echo $CHANGED | jq -R -s -c 'split(" ") | map(select(length > 0))')" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Generate base64 for changed blueprints
|
|
||||||
run: |
|
|
||||||
CHANGED_FOLDERS=$(echo '${{ steps.changes.outputs.folders }}' | jq -r '.[]')
|
|
||||||
|
|
||||||
echo "### 📝 Base64 for changed blueprints" > comment.md
|
|
||||||
echo '' >> comment.md
|
echo '' >> comment.md
|
||||||
|
|
||||||
if [ -z "$CHANGED_FOLDERS" ]; then
|
echo "You can use the base64 value to import the blueprint into the UI." >> comment.md
|
||||||
echo "✅ No blueprints changed." >> comment.md
|
echo "<details>" >> comment.md
|
||||||
else
|
echo "<summary>🔍 Show all blueprints base64</summary>" >> comment.md
|
||||||
echo "<details>" >> comment.md
|
echo '' >> comment.md
|
||||||
echo "<summary>🔍 Show base64</summary>" >> comment.md
|
|
||||||
echo '' >> comment.md
|
|
||||||
|
|
||||||
for dir in $CHANGED_FOLDERS; do
|
for dir in blueprints/*; do
|
||||||
echo "Processing $dir..."
|
if [ -d "$dir" ]; then
|
||||||
|
TEMPLATE_NAME=$(basename "$dir")
|
||||||
|
|
||||||
COMPOSE_FILE="blueprints/$dir/docker-compose.yml"
|
COMPOSE_FILE="$dir/docker-compose.yml"
|
||||||
TEMPLATE_FILE="blueprints/$dir/template.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")
|
||||||
@@ -46,21 +41,26 @@ jobs:
|
|||||||
JSON="{\"compose\":$COMPOSE_CONTENT,\"config\":$TEMPLATE_CONTENT}"
|
JSON="{\"compose\":$COMPOSE_CONTENT,\"config\":$TEMPLATE_CONTENT}"
|
||||||
BASE64_JSON=$(echo -n "$JSON" | base64 -w 0)
|
BASE64_JSON=$(echo -n "$JSON" | base64 -w 0)
|
||||||
|
|
||||||
echo "#### $dir" >> comment.md
|
echo "#### $TEMPLATE_NAME" >> comment.md
|
||||||
echo '' >> comment.md
|
echo '' >> comment.md
|
||||||
echo '```' >> comment.md
|
echo '```' >> comment.md
|
||||||
echo "$BASE64_JSON" >> comment.md
|
echo "$BASE64_JSON" >> comment.md
|
||||||
echo '```' >> comment.md
|
echo '```' >> comment.md
|
||||||
echo ''
|
echo ''
|
||||||
else
|
|
||||||
echo "❌ Missing files in $dir" >> comment.md
|
|
||||||
fi
|
fi
|
||||||
done
|
fi
|
||||||
|
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'
|
||||||
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