-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (90 loc) · 3.33 KB
/
pr-updated-sdk.yml
File metadata and controls
92 lines (90 loc) · 3.33 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
84
85
86
87
88
89
90
91
92
name: "Create PR if OpenDota API has been updated"
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
diff-spec:
name: "Find difference between downloaded specification and current"
runs-on: ubuntu-latest
outputs:
state: ${{steps.compare_state.outputs.state}}
markdown-changes: ${{steps.markdown_changes.outputs.content}}
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Download new OpenDota API spec"
run: wget https://api.opendota.com/api --output-document spec.json
- name: "Convert downloaded spec to v3"
run: |
curl --request POST \
--data @spec.json \
--header 'Content-Type: application/json' \
'https://converter.swagger.io/api/convert' \
--output spec.json
shell: bash
- name: "Compare downloaded specification and current"
uses: swimmwatch/openapi-diff-action@v1.0.1
id: compare_state
with:
old-spec: ".openapi-generator/spec.json"
new-spec: "spec.json"
markdown: "changes.md"
- name: "Read changes.md file"
id: markdown_changes
uses: juliangruber/read-file-action@v1
with:
path: "changes.md"
- name: "Upload downloaded specification for next job"
uses: actions/upload-artifact@v3
with:
name: "downloaded_spec"
path: "spec.json"
create-pr:
name: "Create PR"
runs-on: ubuntu-latest
needs:
- diff-spec
if: needs.diff-spec.outputs.state != 'no_changes'
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Get downloaded specification from 'diff-spec' job"
uses: actions/download-artifact@v3
with:
name: "downloaded_spec"
- name: "Update old specification file"
run: mv spec.json .openapi-generator/spec.json
- name: 'Get previous tag'
id: get-latest-tag
uses: actions-ecosystem/action-get-latest-tag@v1
- name: "Detect appropriate new package version"
uses: swimmwatch/openapi-diff-semver-bump@v1.0.2
id: updated-version
with:
package-version: ${{ steps.get-latest-tag.outputs.tag }}
updated-state: ${{ needs.diff-spec.outputs.state }}
- name: "Generate SDK"
uses: ./.github/actions/generate-sdk
with:
package-version: ${{ steps.updated-version.outputs.new-package-version }}
spec-path: ".openapi-generator/spec.json"
- name: "Stage changes"
run: |
sudo chown -R $USER:$USER .git/*;
shell: bash
- name: "Create PR"
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.PAT }}
base: "dev"
branch: "update-v${{ steps.updated-version.outputs.new-package-version }}"
title: "Update package to v${{ steps.updated-version.outputs.new-package-version }}"
labels: |
enhancement
body: ${{ needs.diff-spec.outputs.markdown-changes }}
assignees: "swimmwatch"
reviewers: "swimmwatch"
committer: "GitHub <noreply@github.com>"
commit-message: "Update package to v${{ steps.updated-version.outputs.new-package-version }}"
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>