forked from opendatahub-io/opendatahub-operator
-
Notifications
You must be signed in to change notification settings - Fork 1
65 lines (65 loc) · 2.68 KB
/
check-api-updates.yaml
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
name: Check config and readme updates
on:
pull_request:
paths:
- "apis/**"
jobs:
file-updates:
permissions: write-all
name: Test file updates
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: run make commands
run: |
make generate && make manifests && make api-docs
- name: check git status
id: git_status
run : |
if [[ -n $(git status -s) ]]
then
echo "New files to commit available"
echo "is_files_to_commit_present=true" >> $GITHUB_OUTPUT
delim=""
config_files_joined=""
files=$(git status --porcelain | egrep "apis|config" | cut -b4-)
for file in $files; do
config_files_joined="$config_files_joined$delim$file"
delim=","
done
echo "config_files=$config_files_joined" >> $GITHUB_OUTPUT
delim=""
docs_files_joined=""
files=$(git status --porcelain | egrep "docs/api-overview.md" | cut -b4-)
for file in $files; do
docs_files_joined="$docs_files_joined$delim$file"
delim=","
done
echo "docs_files=$docs_files_joined" >> $GITHUB_OUTPUT
else
echo "No new files to commit"
echo "is_files_to_commit_present=false" >> $GITHUB_OUTPUT
fi
- uses: actions/github-script@v7
if: ${{ steps.git_status.outputs.is_files_to_commit_present == 'true' }}
name: generate comments
env:
DOCS_FILES: ${{ steps.git_status.outputs.docs_files }}
CONFIG_FILES: ${{ steps.git_status.outputs.config_files }}
BRANCH_NAME: ${{ github.head_ref }}
with:
script: |
const { DOCS_FILES, CONFIG_FILES, BRANCH_NAME } = process.env
function getFileList(fileStr){
return fileStr.split(",").reduce((acc, curr)=>{
acc += `- https://github.com/${context.actor}/${context.repo.name}/tree/${BRANCH_NAME}/${curr}\n`
return acc
},"")
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## Important Message ❌\nThis PR cannot be merged as some files need to be updated.\n\nPlease run \`make generate && make manifests\` to update the following files:\n\n ${getFileList(CONFIG_FILES)}\nPlease run \`make api-docs\` to update the following files:\n\n${getFileList(DOCS_FILES)}`
})
core.setFailed("Please update the config and readme files using make commands")