| 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@v6 |
| 26 |
|
| 27 |
- name: Set up Python |
| 28 |
uses: actions/setup-python@v6 |
| 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 |
| 36 |
|
| 37 |
- name: Run discovery |
| 38 |
id: discovery |
| 39 |
run: | |
| 40 |
python scripts/well-known-discovery.py |
| 41 |
continue-on-error: true |
| 42 |
|
| 43 |
- name: Detect changes |
| 44 |
id: diff |
| 45 |
run: | |
| 46 |
git status --porcelain > diff-summary.txt |
| 47 |
if [[ -n "$(git status --porcelain)" ]]; then |
| 48 |
echo "changed=true" >> $GITHUB_OUTPUT |
| 49 |
else |
| 50 |
echo "changed=false" >> $GITHUB_OUTPUT |
| 51 |
fi |
| 52 |
- name: Configure Git |
| 53 |
if: steps.diff.outputs.changed == 'true' |
| 54 |
run: | |
| 55 |
git config --global user.name "github-actions[bot]" |
| 56 |
git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 57 |
- name: Prepare PR body |
| 58 |
if: steps.diff.outputs.changed == 'true' |
| 59 |
run: | |
| 60 |
{ |
| 61 |
echo "## 🔍 Change summary" |
| 62 |
echo |
| 63 |
echo '```json' |
| 64 |
cat diff-summary.txt |
| 65 |
echo |
| 66 |
echo '```' |
| 67 |
echo |
| 68 |
echo '_This PR contains automated changes made by the 🤖 well-known-discovery workflow._' |
| 69 |
} > pr-body.md |
| 70 |
|
| 71 |
- name: Commit and push changes |
| 72 |
if: steps.diff.outputs.changed == 'true' |
| 73 |
run: | |
| 74 |
git checkout -b well-known-discovery-update-$(date +%Y%m%d%H%M%S) |
| 75 |
git add well-known-snapshots/latest.json |
| 76 |
git commit -m "🤖 update Cookidoo API discovery snapshot" |
| 77 |
git push origin HEAD |
| 78 |
env: |
| 79 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 80 |
|
| 81 |
- name: Create pull request |
| 82 |
if: steps.diff.outputs.changed == 'true' |
| 83 |
run: | |
| 84 |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) |
| 85 |
gh pr create --base master --head $BRANCH_NAME --title '🤖 update Cookidoo API discovery snapshot' --body-file pr-body.md |
| 86 |
PR_NUMBER=$(gh pr view --json number -q ".number") |
| 87 |
gh pr edit $PR_NUMBER --add-label ":boom: breaking change" |
| 88 |
env: |
| 89 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |