Skip to content

Commit d660b4f

Browse files
committed
[UPDATE] the flow to only run in specific conditions and if triggered by a tag, trigger itself with an empty commit on the main branch.
1 parent ceb181e commit d660b4f

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

.github/workflows/document_generator.yaml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
name: doxygen_generator
22

33
# version: 1.0.0
4-
# 1.0.1 # removed the need of secrets for the user e-mail and name.
5-
# 1.0.2 # change the tag to only trigger when a -doc is appended to it.
4+
# 1.0.1 # Removed the need of secrets for the user e-mail and name.
5+
# 1.0.2 # Change the tag to only trigger when a -doc is appended to it.
66
# 1.0.3 # Update the way the tag is processed in the flow.
7-
# 1.0.4 # the page is now published from the main branch regardless of the branch having triggered the flow.
7+
# 1.0.4 # The page is now published from the main branch regardless of the branch having triggered the flow.
8+
# 1.0.5 # The flow will only run specific parts of itself depending on the trigger method
9+
# 1.0.6 # The flow will trigger the push method after the initial trigger if it had been triggered by a tag
810

911
on:
1012
push:
@@ -274,7 +276,7 @@ jobs:
274276
path: ${{ env.TEMPORARY_FOLDER }}
275277
enableCrossOsArchive: true
276278

277-
publish_html:
279+
publish_html: # The critical steps will only be run if the flow was triggered by a push on the main branch
278280
# environment variables that are for the github pages
279281
environment:
280282
name: github-pages
@@ -292,6 +294,7 @@ jobs:
292294

293295
- name: Get generated documentation
294296
id: html-cache-restore
297+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/')
295298
uses: actions/cache@v4
296299
with:
297300
key: ${{ env.CACHE_KEY_CLEANED }}
@@ -321,7 +324,7 @@ jobs:
321324
id: deployment
322325
uses: actions/deploy-pages@v4
323326

324-
export_other_formats_when_present:
327+
export_other_formats_when_present: # The critical steps will only be run if the flow was triggered by a tag.
325328
runs-on: ubuntu-latest
326329
needs: clean_up_generation
327330
if: success()
@@ -518,6 +521,22 @@ jobs:
518521
make_latest: true
519522
token: ${{ secrets.GITHUB_TOKEN }}
520523

524+
- name: Trigger empty push to main
525+
if: startsWith(github.ref, 'refs/tags/')
526+
run: |
527+
git config --global user.name "${GITHUB_ACTOR}"
528+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
529+
530+
# Fetch and switch to main
531+
git fetch origin main:main
532+
git checkout main
533+
534+
# Create empty commit
535+
git commit --allow-empty -m "Trigger HTML deployment from tag ${{ github.ref_name }}"
536+
537+
# Push back to main
538+
git push origin main
539+
521540
clean_created_cache:
522541
name: Clear the cache generated during the build time
523542
permissions: write-all

0 commit comments

Comments
 (0)