-
Notifications
You must be signed in to change notification settings - Fork 42
89 lines (77 loc) · 2.69 KB
/
nightly.yml
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Run nightly tests
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
pr_number:
description: 'Specify a PR number to run tests on (optional)'
required: false
type: string
defaults:
run:
shell: bash
jobs:
identify-prs:
runs-on: ubuntu-latest
outputs:
pr-data: ${{ steps.get-prs.outputs.pr-data }}
steps:
- name: Identify Open Non-Draft PRs with Recent Commits (or Specific PR)
id: get-prs
uses: actions/github-script@v6
with:
script: |
const oneDayAgo = new Date();
oneDayAgo.setDate(oneDayAgo.getDate() - 1);
const prNumber = '${{ github.event.inputs.pr_number }}';
let prs = [];
if (prNumber) {
// Fetch the specified PR
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: parseInt(prNumber),
});
prs = [pr.data];
} else {
// Fetch all PRs
const allPRs = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
});
prs = allPRs.data.filter(pr => !pr.draft);
}
const filteredPRs = [];
for (const pr of prs) {
// Get commits to check for recent activity
const commits = await github.rest.pulls.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
per_page: 100,
});
const recentCommits = commits.data.filter(commit => {
const commitDate = new Date(commit.commit.author.date);
return commitDate >= oneDayAgo;
});
if (recentCommits.length > 0 || prNumber) {
filteredPRs.push({ branch: pr.head.ref, sha: pr.head.sha, number: pr.number });
}
}
console.log("Filtered PRs:", filteredPRs);
core.setOutput('pr-data', JSON.stringify(filteredPRs));
run-all-tests:
needs: [identify-prs]
if: ${{ needs.identify-prs.outputs.pr-data != '[]' && needs.identify-prs.outputs.pr-data != '' }}
strategy:
matrix:
pr: ${{ fromJson(needs.identify-prs.outputs.pr-data) }}
uses: ./.github/workflows/test-all.yml
with:
branch_name: ${{ matrix.pr.branch }}
sha: ${{ matrix.pr.sha }}
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}