forked from hl7-eu/mpd
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (125 loc) · 4.95 KB
/
deploy.yml
File metadata and controls
154 lines (125 loc) · 4.95 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Validate and Deploy R5
on:
push:
branches: ['**'] # Deploy from any branch to matching branch in R5 repo
workflow_dispatch: # Allow manual triggering
jobs:
# Validation jobs run first
validate-r4:
runs-on: ubuntu-latest
name: Validate R4 IG
steps:
- uses: actions/checkout@v4
- name: Install Jekyll
run: sudo gem install jekyll
- name: Install Sushi
run: sudo npm install -g fsh-sushi
- name: Preprocess
run: |
chmod u+x *.sh
./_preprocessMultiVersion.sh
- name: Update IG publisher
run: |
pwd
chmod +x ./_updatePublisher.sh
./_updatePublisher.sh -y
- name: Validate R4 IG
run: |
pwd
./_genonce.sh
validate-r5:
runs-on: ubuntu-latest
name: Validate R5 IG
steps:
- uses: actions/checkout@v4
- name: Install Jekyll
run: sudo gem install jekyll
- name: Install Sushi
run: sudo npm install -g fsh-sushi
- name: Preprocess
run: |
chmod u+x *.sh
./_preprocessMultiVersion.sh
- name: Update IG publisher
working-directory: ./igs/mpd-r5
run: |
pwd
chmod +x ./_updatePublisher.sh
./_updatePublisher.sh -y
- name: Validate R5 IG
working-directory: ./igs/mpd-r5
run: |
pwd
./_genonce.sh
# Deployment job only runs if validation passes - R5 ONLY
deploy-r5:
runs-on: ubuntu-latest
needs: [validate-r4, validate-r5] # Wait for both validations to pass
if: github.event_name == 'push'
steps:
- name: Checkout source repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for proper branch handling
token: ${{ secrets.DEPLOY_TOKEN || github.token }}
- name: Setup Git configuration
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "actions@github.com"
- name: Preprocess files
run: |
chmod u+x *.sh
./_preprocessMultiVersion.sh
- name: Clone R5 target repository
env:
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
R5_REPO_URL: ${{ vars.R5_REPO_URL || format('{0}/mpd-r5', github.repository_owner) }}
run: |
if [ -z "$DEPLOY_TOKEN" ]; then
echo "Error: DEPLOY_TOKEN secret not configured. Please add a Personal Access Token with repo permissions."
echo "Go to: Settings > Secrets and variables > Actions > New repository secret"
echo "Name: DEPLOY_TOKEN"
echo "Value: Your GitHub Personal Access Token"
exit 1
fi
echo "Deploying R5 to: $R5_REPO_URL"
git clone https://$DEPLOY_TOKEN@github.com/$R5_REPO_URL.git r5-repo
- name: Prepare R5 repository branch
working-directory: ./r5-repo
run: |
# Get current branch name
BRANCH_NAME="${{ github.ref_name }}"
echo "Working with branch: $BRANCH_NAME"
# Check if branch exists remotely
if git ls-remote --heads origin $BRANCH_NAME | grep -q $BRANCH_NAME; then
echo "Branch $BRANCH_NAME exists remotely, checking out"
git checkout $BRANCH_NAME
else
echo "Branch $BRANCH_NAME doesn't exist, creating new branch"
git checkout -b $BRANCH_NAME
fi
- name: Sync R5 content
run: |
# Remove all content from target repo except .git
find ./r5-repo -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
# Copy mpd-r5 content to root of target repository
cp -r ./igs/mpd-r5/* ./r5-repo/
# Ensure hidden files are copied too (excluding .git)
find ./igs/mpd-r5 -name ".*" -not -name ".git" -not -name "." -not -name ".." -exec cp -r {} ./r5-repo/ \; 2>/dev/null || true
- name: Commit and push R5 changes
working-directory: ./r5-repo
run: |
# Create a build trigger file to ensure there's always a commit for auto-ig-builder
echo "Build triggered at: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" > .build-trigger
echo "Source commit: ${{ github.sha }}" >> .build-trigger
echo "Source branch: ${{ github.ref_name }}" >> .build-trigger
git add -A
# Always commit to ensure auto-ig-builder triggers
if git diff --staged --quiet; then
echo "No content changes, but creating trigger commit for auto-ig-builder"
git commit -m "Trigger auto-ig-builder - no content changes - source: ${{ github.sha }}"
else
git commit -m "Auto-sync from mpd repository - commit ${{ github.sha }}"
fi
git push origin ${{ github.ref_name }}
echo "R5 repository updated successfully - auto-ig-builder should trigger"