Skip to content

Commit 994eecf

Browse files
PETOSS 733 | Automation | SDK pipeline | Enable the SDK publish pipeline (#750)
PETOSS 733 | Automation | SDK pipeline | Enable the SDK publish pipeline (#750)
1 parent 8507d28 commit 994eecf

File tree

2 files changed

+204
-0
lines changed

2 files changed

+204
-0
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/[email protected]
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/workflows/publish.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Publish
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
release_number: ${{steps.get_latest_release_number.outputs.release_tag}}
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
steps:
15+
- name: Checkout xero-node repo
16+
uses: actions/checkout@v4
17+
with:
18+
repository: XeroAPI/xero-node
19+
path: xero-node
20+
21+
- name: Set up Node environment
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
cache: 'npm'
26+
cache-dependency-path: '**/package-lock.json'
27+
registry-url: 'https://registry.npmjs.org'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
working-directory: xero-node
32+
33+
- name: Run Build
34+
run: npm run build
35+
working-directory: xero-node
36+
37+
- name: Fetch Latest release number
38+
id: get_latest_release_number
39+
run: |
40+
latest_version=$(gh release view --json tagName --jq '.tagName')
41+
echo "Latest release version is - $latest_version"
42+
echo "::set-output name=release_tag::$latest_version"
43+
working-directory: xero-node
44+
env:
45+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
46+
47+
- name: Publish to npm
48+
env:
49+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
50+
run: npm publish
51+
working-directory: xero-node
52+
53+
notify-slack-on-success:
54+
runs-on: ubuntu-latest
55+
needs: publish
56+
permissions:
57+
contents: read
58+
if: success()
59+
steps:
60+
- name: Checkout xero-node repo
61+
uses: actions/checkout@v4
62+
with:
63+
repository: XeroAPI/xero-node
64+
path: xero-node
65+
66+
- name: Send slack notification on success
67+
uses: ./xero-node/.github/actions/notify-slack
68+
with:
69+
heading_text: "Publish job has succeeded !"
70+
alert_type: "thumbsup"
71+
job_status: "Success"
72+
XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}}
73+
job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
74+
button_type: "primary"
75+
package_version: ${{needs.publish.outputs.release_number}}
76+
repo_link: ${{github.server_url}}/${{github.repository}}
77+
78+
notify-slack-on-failure:
79+
runs-on: ubuntu-latest
80+
needs: publish
81+
permissions:
82+
contents: read
83+
if: failure()
84+
steps:
85+
- name: Checkout xero-node repo
86+
uses: actions/checkout@v4
87+
with:
88+
repository: XeroAPI/xero-node
89+
path: xero-node
90+
91+
- name: Send slack notification on failure
92+
uses: ./xero-node/.github/actions/notify-slack
93+
with:
94+
heading_text: "Publish job has failed !"
95+
alert_type: "alert"
96+
job_status: "Failed"
97+
XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}}
98+
job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
99+
button_type: "danger"
100+
package_version: ${{needs.publish.outputs.release_number}}
101+
repo_link: ${{github.server_url}}/${{github.repository}}

0 commit comments

Comments
 (0)