1+ name : Validate and Deploy to Separate Repositories
2+
3+ on :
4+ push :
5+ branches : ['**'] # Trigger on any branch push
6+ workflow_dispatch : # Allow manual triggering
7+
8+ jobs :
9+ # Validation jobs run first
10+ validate-r4 :
11+ runs-on : ubuntu-latest
12+ name : Validate R4 IG
13+
14+ steps :
15+ - uses : actions/checkout@v4
16+
17+ - name : Install Jekyll
18+ run : sudo gem install jekyll
19+
20+ - name : Install Sushi
21+ run : sudo npm install -g fsh-sushi
22+
23+ - name : Preprocess
24+ run : |
25+ chmod u+x *.sh
26+ ./_preprocessMultiVersion.sh
27+
28+ - name : Update IG publisher
29+ working-directory : ./igs/imaging-r4
30+ run : |
31+ pwd
32+ chmod +x ./_updatePublisher.sh
33+ ./_updatePublisher.sh -y
34+
35+ - name : Validate R4 IG
36+ working-directory : ./igs/imaging-r4
37+ run : |
38+ pwd
39+ ./_genonce.sh
40+
41+ validate-r5 :
42+ runs-on : ubuntu-latest
43+ name : Validate R5 IG
44+
45+ steps :
46+ - uses : actions/checkout@v4
47+
48+ - name : Install Jekyll
49+ run : sudo gem install jekyll
50+
51+ - name : Install Sushi
52+ run : sudo npm install -g fsh-sushi
53+
54+ - name : Preprocess
55+ run : |
56+ chmod u+x *.sh
57+ ./_preprocessMultiVersion.sh
58+
59+ - name : Update IG publisher
60+ working-directory : ./igs/imaging-r5
61+ run : |
62+ pwd
63+ chmod +x ./_updatePublisher.sh
64+ ./_updatePublisher.sh -y
65+
66+ - name : Validate R5 IG
67+ working-directory : ./igs/imaging-r5
68+ run : |
69+ pwd
70+ ./_genonce.sh
71+
72+ # Deployment jobs only run if validation passes
73+ deploy-r4 :
74+ runs-on : ubuntu-latest
75+ needs : [validate-r4, validate-r5] # Wait for both validations to pass
76+ if : github.event_name == 'push'
77+
78+ steps :
79+ - name : Checkout source repository
80+ uses : actions/checkout@v4
81+ with :
82+ fetch-depth : 0 # Fetch full history for proper branch handling
83+ token : ${{ secrets.DEPLOY_TOKEN }}
84+
85+ - name : Setup Git configuration
86+ run : |
87+ git config --global user.name "GitHub Actions Bot"
88+ git config --global user.email "actions@github.com"
89+
90+ - name : Preprocess files
91+ run : |
92+ chmod u+x *.sh
93+ ./_preprocessMultiVersion.sh
94+
95+ - name : Clone R4 target repository
96+ env :
97+ DEPLOY_TOKEN : ${{ secrets.DEPLOY_TOKEN }}
98+ R4_REPO_URL : ${{ vars.R4_REPO_URL || 'oijauregui/ehdsimaging-r4' }}
99+ run : |
100+ git clone https://$DEPLOY_TOKEN@github.com/$R4_REPO_URL.git r4-repo
101+
102+ - name : Prepare R4 repository branch
103+ working-directory : ./r4-repo
104+ run : |
105+ # Get current branch name
106+ BRANCH_NAME="${{ github.ref_name }}"
107+ echo "Working with branch: $BRANCH_NAME"
108+
109+ # Check if branch exists remotely
110+ if git ls-remote --heads origin $BRANCH_NAME | grep -q $BRANCH_NAME; then
111+ echo "Branch $BRANCH_NAME exists remotely, checking out"
112+ git checkout $BRANCH_NAME
113+ else
114+ echo "Branch $BRANCH_NAME doesn't exist, creating new branch"
115+ git checkout -b $BRANCH_NAME
116+ fi
117+
118+ - name : Sync R4 content
119+ run : |
120+ # Remove all content from target repo except .git
121+ find ./r4-repo -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
122+
123+ # Copy imaging-r4 content to root of target repository
124+ cp -r ./igs/imaging-r4/* ./r4-repo/
125+
126+ # Ensure hidden files are copied too (excluding .git)
127+ find ./igs/imaging-r4 -name ".*" -not -name ".git" -not -name "." -not -name ".." -exec cp -r {} ./r4-repo/ \; 2>/dev/null || true
128+
129+ - name : Commit and push R4 changes
130+ working-directory : ./r4-repo
131+ run : |
132+ # Create a build trigger file to ensure there's always a commit for auto-ig-builder
133+ echo "Build triggered at: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" > .build-trigger
134+ echo "Source commit: ${{ github.sha }}" >> .build-trigger
135+ echo "Source branch: ${{ github.ref_name }}" >> .build-trigger
136+
137+ git add -A
138+
139+ # Always commit to ensure auto-ig-builder triggers
140+ if git diff --staged --quiet; then
141+ echo "No content changes, but creating trigger commit for auto-ig-builder"
142+ git commit -m "Trigger auto-ig-builder - no content changes - source: ${{ github.sha }}"
143+ else
144+ git commit -m "Auto-sync from imaging repository - commit ${{ github.sha }}"
145+ fi
146+
147+ git push origin ${{ github.ref_name }}
148+ echo "R4 repository updated successfully - auto-ig-builder should trigger"
149+
150+ deploy-r5 :
151+ runs-on : ubuntu-latest
152+ needs : [validate-r4, validate-r5] # Wait for both validations to pass
153+ if : github.event_name == 'push'
154+
155+ steps :
156+ - name : Checkout source repository
157+ uses : actions/checkout@v4
158+ with :
159+ fetch-depth : 0 # Fetch full history for proper branch handling
160+ token : ${{ secrets.DEPLOY_TOKEN }}
161+
162+ - name : Setup Git configuration
163+ run : |
164+ git config --global user.name "GitHub Actions Bot"
165+ git config --global user.email "actions@github.com"
166+
167+ - name : Preprocess files
168+ run : |
169+ chmod u+x *.sh
170+ ./_preprocessMultiVersion.sh
171+
172+ - name : Clone R5 target repository
173+ env :
174+ DEPLOY_TOKEN : ${{ secrets.DEPLOY_TOKEN }}
175+ R5_REPO_URL : ${{ vars.R5_REPO_URL || 'oijauregui/ehdsimaging-r5' }}
176+ run : |
177+ git clone https://$DEPLOY_TOKEN@github.com/$R5_REPO_URL.git r5-repo
178+
179+ - name : Prepare R5 repository branch
180+ working-directory : ./r5-repo
181+ run : |
182+ # Get current branch name
183+ BRANCH_NAME="${{ github.ref_name }}"
184+ echo "Working with branch: $BRANCH_NAME"
185+
186+ # Check if branch exists remotely
187+ if git ls-remote --heads origin $BRANCH_NAME | grep -q $BRANCH_NAME; then
188+ echo "Branch $BRANCH_NAME exists remotely, checking out"
189+ git checkout $BRANCH_NAME
190+ else
191+ echo "Branch $BRANCH_NAME doesn't exist, creating new branch"
192+ git checkout -b $BRANCH_NAME
193+ fi
194+
195+ - name : Sync R5 content
196+ run : |
197+ # Remove all content from target repo except .git
198+ find ./r5-repo -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
199+
200+ # Copy imaging-r5 content to root of target repository
201+ cp -r ./igs/imaging-r5/* ./r5-repo/
202+
203+ # Ensure hidden files are copied too (excluding .git)
204+ find ./igs/imaging-r5 -name ".*" -not -name ".git" -not -name "." -not -name ".." -exec cp -r {} ./r5-repo/ \; 2>/dev/null || true
205+
206+ - name : Commit and push R5 changes
207+ working-directory : ./r5-repo
208+ run : |
209+ # Create a build trigger file to ensure there's always a commit for auto-ig-builder
210+ echo "Build triggered at: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" > .build-trigger
211+ echo "Source commit: ${{ github.sha }}" >> .build-trigger
212+ echo "Source branch: ${{ github.ref_name }}" >> .build-trigger
213+
214+ git add -A
215+
216+ # Always commit to ensure auto-ig-builder triggers
217+ if git diff --staged --quiet; then
218+ echo "No content changes, but creating trigger commit for auto-ig-builder"
219+ git commit -m "Trigger auto-ig-builder - no content changes - source: ${{ github.sha }}"
220+ else
221+ git commit -m "Auto-sync from imaging repository - commit ${{ github.sha }}"
222+ fi
223+
224+ git push origin ${{ github.ref_name }}
225+ echo "R5 repository updated successfully - auto-ig-builder should trigger"
0 commit comments