-
Notifications
You must be signed in to change notification settings - Fork 3
87 lines (73 loc) · 2.36 KB
/
Copy pathupdate-collections.yml
File metadata and controls
87 lines (73 loc) · 2.36 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Update Postman Collections
on:
schedule:
- cron: "0 9 * * 1" # Monday 9am UTC
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23"
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Save old spec
run: |
cd codegen && python3 extract_api_spec.py
cp codegen/api_spec.json /tmp/old_spec.json
- name: Download collections
run: cd codegen && python3 download_collections.py
- name: Run codegen
run: |
cd codegen && python3 extract_api_spec.py
cd codegen && python3 generate_cli.py
- name: Build and vet
run: |
go build -o webex .
go vet ./...
- name: Generate changelog
id: changelog
run: |
DIFF=$(python3 codegen/diff_spec.py /tmp/old_spec.json codegen/api_spec.json)
# Write to file to preserve formatting across steps
echo "$DIFF" > /tmp/spec_diff.md
- name: Check for changes
id: changes
run: |
if git diff --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Create PR
if: steps.changes.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH="auto/update-postman-collections"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -B "$BRANCH"
git add -A
git commit -m "Update Postman collections and regenerate CLI commands"
git push -f origin "$BRANCH"
if ! gh pr list --head "$BRANCH" --state open | grep -q .; then
CHANGELOG=$(cat /tmp/spec_diff.md)
gh pr create \
--title "Update Postman collections" \
--body "$(cat <<EOF
## Summary
Automated update of Postman collections and regenerated CLI commands.
## API Changes
${CHANGELOG}
EOF
)" \
--head "$BRANCH" \
--base main
fi