Skip to content

Commit 04d32d3

Browse files
committed
updated action
1 parent 94998f3 commit 04d32d3

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

.github/workflows/daily-build.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,70 @@ on:
44
workflow_dispatch:
55
schedule:
66
- cron: "0 0 * * *" # Run daily at midnight
7+
8+
jobs:
9+
check_changes_build:
10+
name: Check for updates to documentation or source code
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout CGNS documentation repository (master branch)
14+
uses: actions/[email protected]
15+
with:
16+
ref: master
17+
repository: ${{ github.repository }}
18+
path: repos/cgns_doc
19+
20+
- name: Checkout the CGNS source repository (master branch)
21+
uses: actions/[email protected]
22+
with:
23+
ref: master
24+
repository: 'CGNS/CGNS'
25+
path: repos/cgns_src
26+
27+
- name: Get commit history for docs repository
28+
id: get_commits_doc_repo
29+
run: |
30+
cd repos/cgns_doc
31+
last_day=$(date -d 'yesterday' '+%Y-%m-%d')
32+
first_commit_hash=$(git rev-list --max-count=1 --before="$last_day" HEAD)
33+
echo "FIRST_COMMIT_HASH_DOC_REPO=$first_commit_hash" >> $GITHUB_OUTPUT
34+
35+
- name: Get commit history for source repository
36+
id: get_commits_src_repo
37+
run: |
38+
cd repos/cgns_src
39+
last_day=$(date -d 'yesterday' '+%Y-%m-%d')
40+
first_commit_hash=$(git rev-list --max-count=1 --before="$last_day" HEAD)
41+
echo "FIRST_COMMIT_HASH_SRC_REPO=$first_commit_hash" >> $GITHUB_OUTPUT
42+
43+
- name: Check if any commits exist in either repository
44+
id: has_commits
45+
run: |
46+
if [[ -z "${{ steps.get_commits_doc_repo.outputs.FIRST_COMMIT_HASH_DOC_REPO }}" ]] &&
47+
[[ -z "${{ steps.get_commits_src_repo.outputs.FIRST_COMMIT_HASH_SRC_REPO }}" ]]; then
48+
echo "HAS_COMMITS=false" >> $GITHUB_OUTPUT
49+
else
50+
echo "HAS_COMMITS=true" >> $GITHUB_OUTPUT
51+
fi
52+
53+
- name: Log result and trigger another workflow
54+
run: |
55+
if [[ "${{ steps.has_commits.outputs.HAS_COMMITS }}" == "true" ]]; then
56+
echo "Changes found in the previous day."
57+
# Trigger another workflow
58+
echo "::set-output name=trigger_next_workflow::true"
59+
else
60+
echo "No changes found in the previous day."
61+
fi
62+
63+
- name: Trigger downstream workflow (optional)
64+
uses: actions/github-script@v6
65+
if: ${{ steps.log_result.outputs.trigger_next_workflow }}
66+
with:
67+
script: |
68+
github.actions.createWorkflowDispatch({
69+
owner: 'CGNS',
70+
repo: 'cgns.github.io ',
71+
workflow_id: 'publish.yml',
72+
ref: '${{ github.ref }}'
73+
})

0 commit comments

Comments
 (0)