-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (90 loc) · 3.19 KB
/
deploy-lucidchart.yml
File metadata and controls
102 lines (90 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Deploy to Lucidchart
on:
# push:
# branches:
# - main
# paths:
# - '**/*.drawio'
# - '.github/workflows/deploy-lucidchart.yml'
# - '.github/scripts/deploy-to-lucidchart.sh'
workflow_dispatch:
workflow_call:
inputs:
changed_files:
description: 'Comma-separated list of changed files, or "all"'
required: false
type: string
default: 'all'
secrets:
LUCID_TOKEN:
required: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 2 # Fetch HEAD and HEAD~1 to detect changes
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq curl
- name: Detect changed draw.io files
id: changes
run: |
# For manual workflow dispatch, deploy all files
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
echo "changed_files=all" >> $GITHUB_OUTPUT
exit 0
fi
# Detect changed .drawio files
changed_files=$(git diff --name-only HEAD~1 HEAD | grep '\.drawio$' | tr '\n' ',' | sed 's/,$//')
if [ -n "$changed_files" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
echo "changed_files=$changed_files" >> $GITHUB_OUTPUT
echo "Changed draw.io files: $changed_files"
else
echo "changes=false" >> $GITHUB_OUTPUT
echo "No draw.io files changed"
fi
- name: Deploy to Lucidchart
if: steps.changes.outputs.changes == 'true'
env:
LUCID_TOKEN: ${{ secrets.LUCID_TOKEN }}
CHANGED_FILES: ${{ steps.changes.outputs.changed_files }}
run: |
chmod +x .github/scripts/deploy-to-lucidchart.sh
if [ "$CHANGED_FILES" = "all" ]; then
.github/scripts/deploy-to-lucidchart.sh --force
else
.github/scripts/deploy-to-lucidchart.sh --deploy-changed
fi
- name: Commit deployment hashes
if: steps.changes.outputs.changes == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
if [ -d ".github/.deployment-hashes/lucidchart" ]; then
git add .github/.deployment-hashes/lucidchart/
if git diff --staged --quiet; then
echo "No hash changes to commit"
else
git commit -m "Update Lucidchart deployment hashes [skip ci]"
git push
fi
fi
- name: Report deployment status
if: always() && steps.changes.outputs.changes == 'true'
run: |
if [ $? -eq 0 ]; then
echo "✅ Successfully deployed draw.io diagrams to Lucidchart"
else
echo "❌ Failed to deploy draw.io diagrams to Lucidchart"
exit 1
fi
- name: Skip deployment
if: steps.changes.outputs.changes != 'true'
run: |
echo "⏭️ No draw.io files changed, skipping deployment"