-
Notifications
You must be signed in to change notification settings - Fork 2
83 lines (78 loc) · 3 KB
/
Copy pathapi-reference.yml
File metadata and controls
83 lines (78 loc) · 3 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
name: API Reference
# Keeps skills/vaadin-playwright-test/api-reference.md in lock-step with the code.
#
# - On push (master / issue branches): regenerate and commit the result back to
# the branch, so the reference updates itself with no manual step.
# - On pull_request: regenerate and FAIL if the committed file is stale. Push
# events from a fork have a read-only token and cannot auto-commit, so this
# verify-only job is what catches an out-of-date reference in a fork PR.
#
# The push path filter excludes api-reference.md itself, so the bot's own commit
# does not re-trigger the workflow (no loop).
on:
push:
branches:
- master
- 'issue-**'
paths:
- 'src/main/java/org/vaadin/addons/dramafinder/element/**'
- 'tools/generate-api-reference.java'
- '.github/workflows/api-reference.yml'
pull_request:
branches: [ master ]
paths:
- 'src/main/java/org/vaadin/addons/dramafinder/element/**'
- 'tools/generate-api-reference.java'
- '.github/workflows/api-reference.yml'
permissions:
contents: write
jobs:
update-api-reference:
# Auto-commit path — only on push (needs write access to the branch).
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set up JBang
uses: jbangdev/setup-jbang@main
- name: Regenerate API reference
run: jbang tools/generate-api-reference.java
- name: Commit the regenerated reference if it changed
run: |
if git diff --quiet skills/vaadin-playwright-test/api-reference.md; then
echo "api-reference.md is already up to date."
else
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add skills/vaadin-playwright-test/api-reference.md
git commit -m "Regenerate api-reference.md [skip ci]"
git push origin HEAD:${{ github.ref_name }}
fi
verify-api-reference:
# Verify-only path — for pull requests (incl. forks, whose token is read-only).
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set up JBang
uses: jbangdev/setup-jbang@main
- name: Regenerate API reference
run: jbang tools/generate-api-reference.java
- name: Fail if the committed reference is out of date
run: |
if ! git diff --exit-code skills/vaadin-playwright-test/api-reference.md; then
echo "::error::api-reference.md is stale. Run 'jbang tools/generate-api-reference.java' and commit the result."
exit 1
fi