Debian Codegraph @

.github/workflows/well-known-discovery.yaml

raw
1 name: Cookidoo API Discovery of Well Known HAL Endpoint
2
3 on:
4 schedule:
5 - cron: "0 3 1 * *"
6 workflow_dispatch:
7
8 permissions:
9 contents: write
10 pull-requests: write
11
12 env:
13 python-version: "3.12"
14
15 concurrency:
16 group: "well-known-discovery" # Make sure, to not run multiple smoke tests at the same time
17 cancel-in-progress: false
18
19 jobs:
20 discover:
21 runs-on: ubuntu-latest
22
23 steps:
24 - name: Checkout repository
25 uses: actions/checkout@v7
26
27 - name: Set up Python
28 uses: actions/setup-python@v7
29 with:
30 python-version: ${{ env.python-version }}
31
32 - name: Install dependencies
33 run: |
34 python -m pip install --upgrade pip
35 pip install requests~=2.32
36 pip install -e .
37
38 - name: Run discovery
39 id: discovery
40 run: |
41 python scripts/well-known-discovery.py
42 continue-on-error: true
43
44 - name: Detect changes
45 id: diff
46 run: |
47 git status --porcelain > diff-summary.txt
48 if [[ -n "$(git status --porcelain)" ]]; then
49 echo "changed=true" >> $GITHUB_OUTPUT
50 else
51 echo "changed=false" >> $GITHUB_OUTPUT
52 fi
53 - name: Configure Git
54 if: steps.diff.outputs.changed == 'true'
55 run: |
56 git config --global user.name "github-actions[bot]"
57 git config --global user.email "github-actions[bot]@users.noreply.github.com"
58 - name: Prepare PR body
59 if: steps.diff.outputs.changed == 'true'
60 run: |
61 {
62 echo "## 🔍 Change summary"
63 echo
64 echo "Detected changes to endpoints used by cookidoo-api (see"
65 echo "\`cookidoo_api/well_known.py\`'s \`ENDPOINT_RELS\`):"
66 echo
67 echo '```json'
68 cat diff-summary.json
69 echo
70 echo '```'
71 echo
72 echo '_This PR contains automated changes made by the 🤖 well-known-discovery workflow._'
73 } > pr-body.md
74
75 - name: Commit and push changes
76 if: steps.diff.outputs.changed == 'true'
77 run: |
78 git checkout -b well-known-discovery-update-$(date +%Y%m%d%H%M%S)
79 git add well-known-snapshots/latest.json
80 git commit -m "🤖 update Cookidoo API discovery snapshot"
81 git push origin HEAD
82 env:
83 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84
85 - name: Create pull request
86 if: steps.diff.outputs.changed == 'true'
87 run: |
88 BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
89 gh pr create --base master --head $BRANCH_NAME --title '🤖 update Cookidoo API discovery snapshot' --body-file pr-body.md
90 PR_NUMBER=$(gh pr view --json number -q ".number")
91 gh pr edit $PR_NUMBER --add-label ":boom: breaking change"
92 env:
93 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}