|
7 | 7 | workflow_dispatch: |
8 | 8 |
|
9 | 9 | jobs: |
| 10 | + check-activity: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + should_build: ${{ steps.check.outputs.should_build }} |
| 14 | + steps: |
| 15 | + - name: Check for recent commits |
| 16 | + id: check |
| 17 | + run: | |
| 18 | + REPOS='["https://github.com/efcs/llvm-project/tree/contracts-nightly"]' |
| 19 | + STALE_DAYS=7 |
| 20 | +
|
| 21 | + SINCE_DATE=$(date -d "${STALE_DAYS} days ago" --iso-8601=seconds) |
| 22 | + echo "Checking for commits since ${SINCE_DATE} (${STALE_DAYS} days ago)" |
| 23 | + HAS_RECENT=false |
| 24 | +
|
| 25 | + for repo in $(echo "$REPOS" | jq -r '.[]'); do |
| 26 | + REPO_PATH=$(echo "$repo" | sed -E 's|https://github.com/([^/]+/[^/]+).*|\1|') |
| 27 | + BRANCH=$(echo "$repo" | sed -n -E 's|https://github.com/[^/]+/[^/]+/tree/(.+)|\1|p') |
| 28 | +
|
| 29 | + if [ -n "$BRANCH" ]; then |
| 30 | + echo "Checking $REPO_PATH (branch: $BRANCH) for recent commits..." |
| 31 | + COMMITS=$(curl -sf "https://api.github.com/repos/${REPO_PATH}/commits?sha=${BRANCH}&since=${SINCE_DATE}&per_page=1" || echo "[]") |
| 32 | + else |
| 33 | + echo "Checking $REPO_PATH (default branch) for recent commits..." |
| 34 | + COMMITS=$(curl -sf "https://api.github.com/repos/${REPO_PATH}/commits?since=${SINCE_DATE}&per_page=1" || echo "[]") |
| 35 | + fi |
| 36 | +
|
| 37 | + if [ "$(echo "$COMMITS" | jq 'length')" -gt 0 ]; then |
| 38 | + echo "Found recent commits in $repo" |
| 39 | + HAS_RECENT=true |
| 40 | + break |
| 41 | + fi |
| 42 | + done |
| 43 | +
|
| 44 | + if [ "$HAS_RECENT" = "true" ]; then |
| 45 | + echo "should_build=true" >> "$GITHUB_OUTPUT" |
| 46 | + else |
| 47 | + echo "No recent commits in any repo (within ${STALE_DAYS} days), skipping build" |
| 48 | + echo "should_build=false" >> "$GITHUB_OUTPUT" |
| 49 | + fi |
| 50 | +
|
10 | 51 | daily-build: |
| 52 | + needs: check-activity |
| 53 | + if: ${{ needs.check-activity.outputs.should_build == 'true' }} |
11 | 54 | runs-on: [ 'self-hosted', 'ce', 'linux', 'x64' ] |
12 | 55 | steps: |
13 | 56 | - name: Start from a clean directory |
|
0 commit comments