-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (90 loc) · 3.85 KB
/
build.yml
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Build PHP client
on:
pull_request:
concurrency:
# On the main branch we want all builds to complete, even if new commits are merged.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ !contains(github.ref, 'main')}}
jobs:
build-php:
if: "!contains(github.head_ref, 'release-please')"
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Cache generator dependencies
uses: actions/cache@v4
with:
path: generator/vendor
key: ${{ runner.os }}-generator-vendor-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-generator-vendor-
- name: Generate our client
run: make build
# Commit all changed files back to the repository
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "feat(generator): new client automatically generated in GitHub Actions"
openapi:
if: "!contains(github.head_ref, 'release-please')"
runs-on: ubuntu-latest
steps:
- name: Check out the base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Copy the spec files to /tmp for comparison
run: |
cp katapult-core-openapi.json /tmp/katapult-core-openapi.json
cp katapult-public-openapi.json /tmp/katapult-public-openapi.json
- name: Check out the current branch
uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node_modules-
- name: Install openapi-changes
run: npm install
- name: Katapult Core API Spec Changes
id: core-changes
run: |
set +e
echo "core_changes<<EOF" >> $GITHUB_OUTPUT
npx openapi-changes summary --no-logo --no-color --markdown /tmp/katapult-core-openapi.json katapult-core-openapi.json >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
npx openapi-changes html-report /tmp/katapult-core-openapi.json katapult-core-openapi.json
if [ -f report.html ]; then mv report.html openapi-core-report.html; fi
- name: Katapult Public API Spec Changes
id: public-changes
run: |
set +e
echo "public_changes<<EOF" >> $GITHUB_OUTPUT
npx openapi-changes summary --no-logo --no-color --markdown /tmp/katapult-public-openapi.json katapult-public-openapi.json >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
npx openapi-changes html-report /tmp/katapult-public-openapi.json katapult-public-openapi.json
if [ -f report.html ]; then mv report.html openapi-public-report.html; fi
- name: Emit changes in GHA runs
run: echo ${{ steps.core-changes.outputs.core_changes }}
continue-on-error: true
- name: Emit changes in GHA runs
run: echo ${{ steps.public-changes.outputs.public_changes }}
continue-on-error: true
- name: Upload HTML reports as artefacts
id: upload-report
uses: actions/upload-artifact@v4
with:
name: openapi-changes
path: openapi-*-report.html
if-no-files-found: ignore
- name: Add/update a comment on the PR with the changes for the two APIs
uses: mshick/add-pr-comment@v2
with:
message: |
## Download Reports
[Download the OpenAPI Changes Report](${{ steps.upload-report.outputs.artifact-url }})
## Core API Changes
${{ steps.core-changes.outputs.core_changes || 'No changes.' }}
## Public API Changes
${{ steps.public-changes.outputs.public_changes || 'No changes.' }}