Skip to content

Commit 004aae9

Browse files
author
sangeet-joy_xero
committed
added the publish pipeline logic
1 parent 9cac10b commit 004aae9

File tree

2 files changed

+204
-0
lines changed

2 files changed

+204
-0
lines changed
+103
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

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