-
Notifications
You must be signed in to change notification settings - Fork 37
67 lines (59 loc) · 2.42 KB
/
build-daily-cppfront.yml
File metadata and controls
67 lines (59 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
### DO NOT EDIT - created by a script ###
name: cppfront via misc trunk
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
check-activity:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check.outputs.should_build }}
steps:
- name: Check for recent commits
id: check
run: |
REPOS='["https://github.com/hsutter/cppfront/tree/main"]'
STALE_DAYS=7
SINCE_DATE=$(date -d "${STALE_DAYS} days ago" --iso-8601=seconds)
echo "Checking for commits since ${SINCE_DATE} (${STALE_DAYS} days ago)"
HAS_RECENT=false
for repo in $(echo "$REPOS" | jq -r '.[]'); do
REPO_PATH=$(echo "$repo" | sed -E 's|https://github.com/([^/]+/[^/]+).*|\1|')
BRANCH=$(echo "$repo" | sed -n -E 's|https://github.com/[^/]+/[^/]+/tree/(.+)|\1|p')
if [ -n "$BRANCH" ]; then
echo "Checking $REPO_PATH (branch: $BRANCH) for recent commits..."
COMMITS=$(curl -sf "https://api.github.com/repos/${REPO_PATH}/commits?sha=${BRANCH}&since=${SINCE_DATE}&per_page=1" || echo "[]")
else
echo "Checking $REPO_PATH (default branch) for recent commits..."
COMMITS=$(curl -sf "https://api.github.com/repos/${REPO_PATH}/commits?since=${SINCE_DATE}&per_page=1" || echo "[]")
fi
if [ "$(echo "$COMMITS" | jq 'length')" -gt 0 ]; then
echo "Found recent commits in $repo"
HAS_RECENT=true
break
fi
done
if [ "$HAS_RECENT" = "true" ]; then
echo "should_build=true" >> "$GITHUB_OUTPUT"
else
echo "No recent commits in any repo (within ${STALE_DAYS} days), skipping build"
echo "should_build=false" >> "$GITHUB_OUTPUT"
fi
daily-build:
needs: check-activity
if: ${{ needs.check-activity.outputs.should_build == 'true' }}
runs-on: [ 'self-hosted', 'ce', 'linux', 'x64', 'small' ]
steps:
- name: Start from a clean directory
uses: AutoModality/action-clean@v1.1.0
- uses: actions/checkout@v4
- name: Run the build
uses: ./.github/actions/daily-build
with:
image: misc
name: cppfront
command: build-cppfront.sh
args: trunk
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}