Skip to content

Update Postman Collections #1

Update Postman Collections

Update Postman Collections #1

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