CGNS documentation daily build from previous day (master) #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CGNS documentation daily build from previous day (master) | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" # Run daily at midnight | |
jobs: | |
check_changes_build: | |
name: Check for updates to documentation or source code | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout CGNS documentation repository (master branch) | |
uses: actions/[email protected] | |
with: | |
ref: master | |
repository: ${{ github.repository }} | |
path: repos/cgns_doc | |
- name: Checkout the CGNS source repository (master branch) | |
uses: actions/[email protected] | |
with: | |
ref: master | |
repository: 'CGNS/CGNS' | |
path: repos/cgns_src | |
- name: Get commit history for docs repository | |
id: get_commits_doc_repo | |
run: | | |
cd repos/cgns_doc | |
last_day=$(date -d 'yesterday' '+%Y-%m-%d') | |
commit_count=$(git log --after="$last_day 00:00:00" --before="$last_day 23:59:59" --oneline | wc -l) | |
echo "COMMIT_COUNT_DOC_REPO=$commit_count" >> $GITHUB_OUTPUT | |
- name: Get commit history for source repository | |
id: get_commits_src_repo | |
run: | | |
cd repos/cgns_src | |
last_day=$(date -d 'yesterday' '+%Y-%m-%d') | |
commit_count=$(git log --after="$last_day 00:00:00" --before="$last_day 23:59:59" --oneline | wc -l) | |
echo "COMMIT_COUNT_SRC_REPO=$commit_count" >> $GITHUB_OUTPUT | |
- name: Check if any commits exist in either repository | |
id: has_commits | |
run: | | |
if [[ "${{ steps.get_commits_doc_repo.outputs.COMMIT_COUNT_DOC_REPO }}" == "0" ]] && | |
[[ "${{ steps.get_commits_src_repo.outputs.COMMIT_COUNT_SRC_REPO }}" == "0" ]]; then | |
echo "HAS_COMMITS=false" >> $GITHUB_OUTPUT | |
else | |
echo "HAS_COMMITS=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Log result and trigger another workflow | |
id: log_result | |
run: | | |
if [[ "${{ steps.has_commits.outputs.HAS_COMMITS }}" == "true" ]]; then | |
echo "trigger_next_workflow=true" >> $GITHUB_OUTPUT | |
echo "Modifications identified from the previous day." | |
else | |
echo "trigger_next_workflow=false" >> $GITHUB_OUTPUT | |
echo "No modifications identified from the previous day." | |
fi | |
- name: Trigger downstream workflow (optional) | |
uses: actions/github-script@v7 | |
if: success() && steps.log_result.outputs.trigger_next_workflow == 'true' | |
with: | |
script: | | |
await github.rest.actions.createWorkflowDispatch({ | |
owner: 'CGNS', | |
repo: 'cgns.github.io', | |
workflow_id: 'publish.yml', | |
ref: 'develop' | |
}) |