Skip to content

Commit 93c9752

Browse files
Merge branch 'master' into feature/prism-changes-ruby
2 parents a268e46 + baa28fa commit 93c9752

File tree

17 files changed

+323
-18
lines changed

17 files changed

+323
-18
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: slack-alert-action
2+
description: "Action to send slack payload to public-sdk-events channel"
3+
4+
inputs:
5+
heading_text:
6+
required: true
7+
description: "Heading of the slack payload"
8+
alert_type:
9+
required: true
10+
description: "type of the slack alert"
11+
job_status:
12+
required: true
13+
description: "status of the job"
14+
XERO_SLACK_WEBHOOK_URL:
15+
required: true
16+
description: "webhook url for channel - public-sdk-events"
17+
job_url:
18+
required: true
19+
description: "job run id link"
20+
button_type:
21+
required: true
22+
description: "color for the check logs button"
23+
package_version:
24+
required: true
25+
description: "released package version"
26+
repo_link:
27+
required: true
28+
description: "link of the repo"
29+
30+
31+
runs:
32+
using: "composite"
33+
34+
steps:
35+
36+
- name: Send slack notification
37+
id: slack
38+
uses: slackapi/slack-github-action@v1.27.0
39+
env:
40+
SLACK_WEBHOOK_URL: ${{inputs.XERO_SLACK_WEBHOOK_URL}}
41+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
42+
with:
43+
payload: |
44+
{
45+
"blocks": [
46+
{
47+
"type": "rich_text",
48+
"elements": [
49+
{
50+
"type": "rich_text_section",
51+
"elements": [
52+
{
53+
"type": "text",
54+
"text": "${{inputs.heading_text}} ",
55+
"style": {
56+
"bold": true
57+
}
58+
},
59+
{
60+
"type": "emoji",
61+
"name": "${{inputs.alert_type}}"
62+
}
63+
]
64+
}
65+
]
66+
},
67+
{
68+
"type": "divider"
69+
},
70+
{
71+
"type": "section",
72+
"fields": [
73+
{
74+
"type": "mrkdwn",
75+
"text": "*Repository:* \n ${{inputs.repo_link}}"
76+
},
77+
{
78+
"type": "mrkdwn",
79+
"text": "*Status:*\n ${{inputs.job_status}}"
80+
},
81+
{
82+
"type": "mrkdwn",
83+
"text": "*Package Version:*\n ${{inputs.package_version}}"
84+
}
85+
]
86+
},
87+
{
88+
"type": "actions",
89+
"elements": [
90+
{
91+
"type": "button",
92+
"text": {
93+
"type": "plain_text",
94+
"text": "Check the logs",
95+
"emoji": true
96+
},
97+
"style": "${{inputs.button_type}}",
98+
"url": "${{inputs.job_url}}"
99+
}
100+
]
101+
}
102+
]
103+
}

.github/octokit/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import {Octokit} from "@octokit/rest";
2+
import {createAppAuth} from "@octokit/auth-app"
3+
4+
export const getAccessToken = async () => {
5+
6+
const {GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY} = process.env
7+
8+
const octoKitInstance = new Octokit({
9+
authStrategy: createAppAuth,
10+
auth: {
11+
appId: GITHUB_APP_ID,
12+
privateKey: GITHUB_APP_PRIVATE_KEY
13+
}
14+
});
15+
16+
const {data: installations} = await octoKitInstance.rest.apps.listInstallations()
17+
18+
console.log("installations -----", installations);
19+
20+
21+
if(!installations.length) {
22+
throw new Error("No Installations found for this github app")
23+
}
24+
25+
const installationId = installations[0].id;
26+
27+
const installationAccessToken = await octoKitInstance.rest.apps.createInstallationAccessToken({installation_id: installationId})
28+
29+
return installationAccessToken.data.token
30+
}

.github/octokit/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "xero-octokit",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"type": "module",
7+
"scripts": {
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"@octokit/auth-app": "^7.1.1",
14+
"@octokit/rest": "^21.0.2"
15+
}
16+
}

.github/workflows/publish.yml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: Publish & Release SDK
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
cab_id:
6+
description: "CAB id for the change/release"
7+
required: true
8+
type: string
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
environment: prod
14+
outputs:
15+
release_number: ${{steps.get_latest_release_number.outputs.release_tag}}
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
steps:
20+
- name: Checkout xero-ruby repo
21+
uses: actions/checkout@v4
22+
with:
23+
repository: XeroAPI/xero-ruby
24+
path: xero-ruby
25+
26+
- name: Fetch Latest release number
27+
id: get_latest_release_number
28+
run: |
29+
latest_version=$(gh release view --json tagName --jq '.tagName')
30+
echo "Latest release version is - $latest_version"
31+
echo "::set-output name=release_tag::$latest_version"
32+
working-directory: xero-ruby
33+
env:
34+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
35+
36+
- name: Set up Ruby environment
37+
uses: ruby/setup-ruby@v1
38+
with:
39+
ruby-version: '3.2.0'
40+
bundler-cache: true
41+
42+
- name: Install dependencies
43+
run: bundle install
44+
working-directory: xero-ruby
45+
46+
- name: Publish to Ruby
47+
env:
48+
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
49+
run: |
50+
gemspec_file=$(ls *.gemspec)
51+
gem_file=$(gem build "$gemspec_file" | grep -o '[^ ]*\.gem')
52+
echo "$gem_file"
53+
gem push "$gem_file"
54+
working-directory: xero-ruby
55+
56+
notify-slack-on-success:
57+
runs-on: ubuntu-latest
58+
needs: publish
59+
if: success()
60+
permissions:
61+
contents: read
62+
steps:
63+
- name: Checkout xero-ruby repo
64+
uses: actions/checkout@v4
65+
with:
66+
repository: XeroAPI/xero-ruby
67+
path: xero-ruby
68+
69+
- name: Send slack notification on success
70+
uses: ./xero-ruby/.github/actions/notify-slack
71+
with:
72+
heading_text: "Publish job has succeeded !"
73+
alert_type: "thumbsup"
74+
job_status: "Success"
75+
XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}}
76+
job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
77+
button_type: "primary"
78+
package_version: ${{needs.publish.outputs.release_number}}
79+
repo_link: ${{github.server_url}}/${{github.repository}}
80+
81+
notify-slack-on-failure:
82+
runs-on: ubuntu-latest
83+
needs: publish
84+
if: failure()
85+
permissions:
86+
contents: read
87+
steps:
88+
- name: Checkout xero-ruby repo
89+
uses: actions/checkout@v4
90+
with:
91+
repository: XeroAPI/xero-ruby
92+
path: xero-ruby
93+
94+
- name: Send slack notification on failure
95+
uses: ./xero-ruby/.github/actions/notify-slack
96+
with:
97+
heading_text: "Publish job has failed !"
98+
alert_type: "alert"
99+
job_status: "Failed"
100+
XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}}
101+
job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
102+
button_type: "danger"
103+
package_version: ${{needs.publish.outputs.release_number}}
104+
repo_link: ${{github.server_url}}/${{github.repository}}
105+
notify-codegen-repo:
106+
needs: publish
107+
if: always()
108+
runs-on: ubuntu-latest
109+
permissions:
110+
contents: write
111+
pull-requests: write
112+
113+
steps:
114+
- name: Checkout
115+
uses: actions/checkout@v4
116+
with:
117+
repository: XeroAPI/xero-ruby
118+
path: xero-ruby
119+
120+
- name: Install octokit dependencies
121+
run: npm i
122+
working-directory: xero-ruby/.github/octokit
123+
124+
- name: Get github app access token
125+
id: get_access_token
126+
env:
127+
GITHUB_APP_ID: ${{ secrets.XERO_CODEGEN_BOT_APPLICATION_ID }}
128+
GITHUB_APP_PRIVATE_KEY: ${{ secrets.XERO_CODEGEN_BOT_APPLICATION_KEY }}
129+
uses: actions/github-script@v7
130+
with:
131+
result-encoding: string
132+
script: |
133+
const { getAccessToken } = await import('${{ github.workspace }}/xero-ruby/.github/octokit/index.js')
134+
const token = await getAccessToken()
135+
return token
136+
137+
- name: Notify codegen repo
138+
run: |
139+
curl -X POST -H "Authorization: token ${{ steps.get_access_token.outputs.result }}" \
140+
-H "Accept: application/vnd.github.v3+json" \
141+
-H "Content-Type: application/json" \
142+
https://api.github.com/repos/xero-internal/xeroapi-sdk-codegen/actions/workflows/notify-sdk-publish.yml/dispatches \
143+
-d '{
144+
"ref": "master",
145+
"inputs": {
146+
"commit": "${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}",
147+
"status": "${{needs.publish.result}}",
148+
"deployer": "xero-codegen-bot",
149+
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
150+
"environment": "prod",
151+
"sdk_type": "ruby",
152+
"cab_key": "${{ github.event.inputs.cab_id }}"
153+
}
154+
}'

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
xero-ruby (11.1.0)
4+
xero-ruby (11.2.0)
55
faraday (>= 2.0, < 3.0)
66
json (~> 2.1, >= 2.1.0)
77
json-jwt (~> 1.16, >= 1.16.3)

docs/accounting/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6339,7 +6339,7 @@
63396339
<nav id="scrollingNav">
63406340
<ul class="sidenav nav nav-list">
63416341
<li class="nav-header" data-group="Accounting"><strong>SDK: </strong><span id='sdk-name'></span></li>
6342-
<li class="nav-header" data-group="Accounting"><strong>VSN: </strong>11.1.0</li>
6342+
<li class="nav-header" data-group="Accounting"><strong>VSN: </strong>11.2.0</li>
63436343
<li class="nav-header" data-group="Accounting"><a href="#api-Accounting">Methods</a></li>
63446344
<li data-group="Accounting" data-name="createAccount" class="">
63456345
<a href="#api-Accounting-createAccount">createAccount</a>

docs/app_store/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@
12411241
<nav id="scrollingNav">
12421242
<ul class="sidenav nav nav-list">
12431243
<li class="nav-header" data-group="AppStore"><strong>SDK: </strong><span id='sdk-name'></span></li>
1244-
<li class="nav-header" data-group="AppStore"><strong>VSN: </strong>11.1.0</li>
1244+
<li class="nav-header" data-group="AppStore"><strong>VSN: </strong>11.2.0</li>
12451245
<li class="nav-header" data-group="AppStore"><a href="#api-AppStore">Methods</a></li>
12461246
<li data-group="AppStore" data-name="getSubscription" class="">
12471247
<a href="#api-AppStore-getSubscription">getSubscription</a>

docs/assets/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@
13901390
<nav id="scrollingNav">
13911391
<ul class="sidenav nav nav-list">
13921392
<li class="nav-header" data-group="Asset"><strong>SDK: </strong><span id='sdk-name'></span></li>
1393-
<li class="nav-header" data-group="Asset"><strong>VSN: </strong>11.1.0</li>
1393+
<li class="nav-header" data-group="Asset"><strong>VSN: </strong>11.2.0</li>
13941394
<li class="nav-header" data-group="Asset"><a href="#api-Asset">Methods</a></li>
13951395
<li data-group="Asset" data-name="createAsset" class="">
13961396
<a href="#api-Asset-createAsset">createAsset</a>

docs/files/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@
11701170
<nav id="scrollingNav">
11711171
<ul class="sidenav nav nav-list">
11721172
<li class="nav-header" data-group="Files"><strong>SDK: </strong><span id='sdk-name'></span></li>
1173-
<li class="nav-header" data-group="Files"><strong>VSN: </strong>11.1.0</li>
1173+
<li class="nav-header" data-group="Files"><strong>VSN: </strong>11.2.0</li>
11741174
<li class="nav-header" data-group="Files"><a href="#api-Files">Methods</a></li>
11751175
<li data-group="Files" data-name="createFileAssociation" class="">
11761176
<a href="#api-Files-createFileAssociation">createFileAssociation</a>

docs/finance/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2716,7 +2716,7 @@
27162716
<nav id="scrollingNav">
27172717
<ul class="sidenav nav nav-list">
27182718
<li class="nav-header" data-group="Finance"><strong>SDK: </strong><span id='sdk-name'></span></li>
2719-
<li class="nav-header" data-group="Finance"><strong>VSN: </strong>11.1.0</li>
2719+
<li class="nav-header" data-group="Finance"><strong>VSN: </strong>11.2.0</li>
27202720
<li class="nav-header" data-group="Finance"><a href="#api-Finance">Methods</a></li>
27212721
<li data-group="Finance" data-name="getAccountingActivityAccountUsage" class="">
27222722
<a href="#api-Finance-getAccountingActivityAccountUsage">getAccountingActivityAccountUsage</a>

0 commit comments

Comments
 (0)