1
+ name : Check Samples
2
+
3
+ on :
4
+ pull_request :
5
+ paths :
6
+ - ' samples/**'
7
+
8
+ jobs :
9
+ check_samples :
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - name : Checkout code
13
+ uses : actions/checkout@v2
14
+
15
+ - name : Check for required files
16
+ run : |
17
+ for changed_file in $(git diff --name-only HEAD^); do
18
+ if [[ $changed_file == samples/* ]]; then
19
+ sample_dir=$(dirname $changed_file)
20
+ if [[ ! -f $sample_dir/README.md || ! -f $sample_dir/compose.yml ]]; then
21
+ echo "Missing README.md or compose.yml in $sample_dir"
22
+ exit 1
23
+ fi
24
+ fi
25
+ done
26
+
27
+ - name : Add checklist to PR description
28
+ uses : actions/github-script@v5
29
+ with :
30
+ script : |
31
+ const pr_number = context.issue.number;
32
+ const checklist = `
33
+ - [ ] I have tested that the sample runs locally
34
+ - [ ] I have tested that the sample runs in Defang Playground
35
+ - [ ] I have tested that the sample runs in BYOC
36
+ - [ ] I have documented any required config in the readme
37
+ - [ ] I have documented how to provision any third-party services in the readme
38
+ - [ ] I have documented how to run the sample in the readme (locally and with Defang)
39
+ `;
40
+
41
+ // Get the current PR
42
+ const { data : pullRequest } = await github.rest.pulls.get({
43
+ owner : context.repo.owner,
44
+ repo : context.repo.repo,
45
+ pull_number : pr_number
46
+ });
47
+
48
+ // Check if the checklist already exists in the PR description
49
+ if (!pullRequest.body.includes(checklist)) {
50
+ // Update the PR description with the checklist
51
+ await github.rest.pulls.update({
52
+ owner : context.repo.owner,
53
+ repo : context.repo.repo,
54
+ pull_number : pr_number,
55
+ body : pullRequest.body + "\n" + checklist
56
+ });
57
+ }
0 commit comments