-
Notifications
You must be signed in to change notification settings - Fork 7
130 lines (110 loc) · 4.91 KB
/
Copy pathgenerate-zapier.yaml
File metadata and controls
130 lines (110 loc) · 4.91 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Generate Zapier integration
on:
repository_dispatch:
types: [generate-zapier]
jobs:
generate-zapier:
runs-on: ubuntu-latest
env:
GIT_REPO_ID: fattureincloud-zapier
GIT_USER_ID: fattureincloud
steps:
- id: init-git
name: Init GIT
run: |
git config --global user.email "info@fattureincloud.it"
git config --global user.name "fattureincloud-bot"
- id: checkout
name: Checkout repo
uses: actions/checkout@v6
with:
token: ${{ secrets.FATTUREINCLOUD_BOT_TOKEN }}
- id: checkout-zapier
name: Checkout zapier repo
env:
GIT_REPO_PATH: "${{ env.GIT_USER_ID }}/${{ env.GIT_REPO_ID }}"
uses: actions/checkout@v6
with:
path: ./generated/zapier
ref: master
repository: ${{ env.GIT_REPO_PATH }}
token: ${{ secrets.FATTUREINCLOUD_BOT_TOKEN }}
- id: setup-node
name: Setup Node.js
uses: actions/setup-node@v6
- id: setup-java
name: Setup Java
uses: actions/setup-java@v5
with:
distribution: "adopt"
java-version: "11"
- id: setup-libraries
name: Install libraries
run: |
npm install -g yarn
yarn global add @apidevtools/swagger-cli @openapitools/openapi-generator-cli standard-version
sudo apt update
sudo apt upgrade
sudo wget -qO /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64"
sudo chmod +x /usr/local/bin/yq
cd ./scripts/
yarn
cd ../generated/zapier/scripts
yarn
- id: bump-zapier-integration-version
name: Bump zapier version
env:
OPENAPI_VERSION: ${{ github.event.client_payload.version }}
run: |
echo "openapi_version=$OPENAPI_VERSION"
cd ./generated/zapier
echo 'Bumping the patch version...'
standard-version --skip.tag --skip.changelog --skip.commit --release-as patch
INTEGRATION_VERSION=$(yq e '.info.version' ./version.yaml)
echo "integration_version=$INTEGRATION_VERSION" >> $GITHUB_ENV
echo "openapi_version=$OPENAPI_VERSION" >> $GITHUB_ENV
- id: delete-old-files
name: Delete old files
run: |
rm -rf ./generated/zapier/apis
rm -rf ./generated/zapier/models
rm -rf ./generated/zapier/samples
rm -f ./generated/zapier/operations/actions.js
# - id: create-zapier-openapi
# name: Create Zapier OpenAPI spec
# run: |
# cp ./openapi.yaml ./openapi-zapier.yaml
# yq e 'del(.paths."/c/{company_id}/subscriptions")' -i ./openapi-zapier.yaml
# yq e 'del(.paths."/c/{company_id}/subscriptions/{subscription_id}")' -i ./openapi-zapier.yaml
# yq e 'del(.paths."/c/{company_id}/subscriptions/{subscription_id}/verify")' -i ./openapi-zapier.yaml
- id: generate-zapier-integration
name: Generate zapier integration
env:
PACKAGE_NAME: "@fattureincloud/zapier"
run: |
INTEGRATION_VERSION=${{ env.integration_version }}
echo "${{ env.integration_version }}"
RELEASE_NOTE="\"bumping version to $INTEGRATION_VERSION\""
# openapi-generator-cli generate -i ./openapi-zapier.yaml -g zapier -o ./generated/zapier/ -t ./templates/openapi-generator/zapier --additional-properties=npmName=${PACKAGE_NAME},npmVersion=${INTEGRATION_VERSION},modelPackage=models,apiPackage=apis --git-repo-id=${GIT_REPO_ID} --git-user-id=${GIT_USER_ID} --release-note=${RELEASE_NOTE} --release-note=${RELEASE_NOTE}
openapi-generator-cli generate -i ./openapi.yaml -g zapier -o ./generated/zapier/ -t ./templates/openapi-generator/zapier --additional-properties=npmName=${PACKAGE_NAME},npmVersion=${INTEGRATION_VERSION},modelPackage=models,apiPackage=apis --git-repo-id=${GIT_REPO_ID} --git-user-id=${GIT_USER_ID} --release-note=${RELEASE_NOTE} --release-note=${RELEASE_NOTE}
node ./scripts/postprocess-zapier.js './generated/zapier/apis/'
- id: lint-code
name: Lint Code Base
continue-on-error: true
run: |
cd ./generated/javascript
npm install
npx eslint --fix ./
npm run format
- id: create-pr
name: Create Pull Request
uses: peter-evans/create-pull-request@v8
with:
path: ./generated/zapier
branch: "devel-${{ env.integration_version }}"
token: "${{ secrets.FATTUREINCLOUD_BOT_TOKEN }}"
delete-branch: true
base: master
commit-message: "chore: bumping version to ${{ env.integration_version }}"
title: "Updating integration to ${{ env.integration_version }}"
body: "New integration verson ${{ env.integration_version }} generated by Github Action from OpenAPI Spec ${{ env.openapi_version }}"