-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-{{ path }}.yaml
More file actions
81 lines (81 loc) · 4.23 KB
/
generate-{{ path }}.yaml
File metadata and controls
81 lines (81 loc) · 4.23 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
name: "Generate: {{ path }}"
on:
workflow_dispatch:
schedule:
- cron: '13 {{ hour }} * * *'
jobs:
supported-versions-matrix:
name: Supported Versions Matrix {{ path }}
runs-on: ubuntu-latest
outputs:
version: {{ "${{ steps.supported-versions-matrix.outputs.lowest }}" }}
steps:
- uses: actions/checkout@v4
- id: supported-versions-matrix
uses: WyriHaximus/github-action-composer-php-versions-in-range@v1
with:
workingDirectory: clients/{{ path }}
generate-{{ path|replace({".": "_"})|lower }}:
name: Generate {{ path }}
runs-on: ubuntu-latest
needs:
- supported-versions-matrix
container:
image: wyrihaximusnet/php:{{ "${{ needs.supported-versions-matrix.outputs.version }}" }}-nts-alpine-slim-dev-root
steps:
- uses: actions/checkout@v4
- uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1
- uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1
with:
working-directory: "clients/{{ path }}"
- name: Download current spec file
run: |
rm etc/specs/{{ path }}/previous.spec.yaml || true
mv etc/specs/{{ path }}/current.spec.yaml etc/specs/{{ path }}/previous.spec.yaml
curl -o etc/specs/{{ path }}/current.spec.yaml {{ specUrl }}
php utils/patch-broken-spec-files.php etc/specs/{{ path }}/current.spec.yaml
- name: Hash specs
id: spec-hash
run: |
php -r 'file_put_contents(getenv("GITHUB_OUTPUT"), "current=" . md5(file_get_contents("etc/specs/{{ path }}/current.spec.yaml")) . "\n", FILE_APPEND);'
php -r 'file_put_contents(getenv("GITHUB_OUTPUT"), "previous=" . md5(file_get_contents("etc/specs/{{ path }}/previous.spec.yaml")) . "\n", FILE_APPEND);'
- name: Look current up spec version
id: look-current-up-spec-version
uses: mikefarah/yq@v4.47.1
with:
cmd: yq '.info.version' 'etc/specs/{{ path }}/current.spec.yaml'
- name: Look previous up spec version
id: look-previous-up-spec-version
uses: mikefarah/yq@v4.47.1
with:
cmd: yq '.info.version' 'etc/specs/{{ path }}/previous.spec.yaml'
- name: Generate spec diff
id: spec-diff
run: |
curl -fsSL https://pb33f.io/openapi-changes/install.sh | sh
echo "Detected Schema changes:" >> "var/detected-schema-changes"
echo "$(openapi-changes summary --markdown --no-color --no-logo etc/specs/{{ path }}/current.spec.yaml etc/specs/{{ path }}/previous.spec.yaml)" >> "var/detected-schema-changes"
cat var/detected-schema-changes
delimiter="$(openssl rand -hex 8)"
echo "diff<<${delimiter}" >> "${GITHUB_OUTPUT}"
echo "$(cat var/detected-schema-changes)" >> "${GITHUB_OUTPUT}"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
- name: Update Client to {{ "${{ steps.look-current-up-spec-version.outputs.result }}" }}
run: |
make generate-client {{ path }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
branch: "{{ path }}/from-{{ "${{ steps.look-current-up-spec-version.outputs.result }}" }}-{{ "${{ steps.spec-hash.outputs.current }}" }}-from-{{ "${{ steps.look-previous-up-spec-version.outputs.result }}" }}-{{ "${{ steps.spec-hash.outputs.current }}" }}"
token: {{ "${{ secrets.SUBSPLIT_GITHUB_TOKEN }}" }}
labels: |
Automated PR
New Version
automerge
Enhancement ✨
{{ path }}
title: "[{{ path }}] Update to {{ "${{ steps.look-current-up-spec-version.outputs.result }}" }}-{{ "${{ steps.spec-hash.outputs.current }}" }} from {{ "${{ steps.look-previous-up-spec-version.outputs.result }}" }}-{{ "${{ steps.spec-hash.outputs.previous }}" }}"
body-path: "var/detected-schema-changes"
commit-message: |
[{{ path }}] Update to {{ "${{ steps.look-current-up-spec-version.outputs.result }}" }}-{{ "${{ steps.spec-hash.outputs.current }}" }} from {{ "${{ steps.look-previous-up-spec-version.outputs.result }}" }}-{{ "${{ steps.spec-hash.outputs.previous }}" }}
{{ "${{ steps.spec-diff.outputs.diff }}" }}