Skip to content

Commit 1a7974d

Browse files
PETOSS 733 | Automation | SDK pipeline | Enable the SDK publish pipeline (#404)
PETOSS 733 | Automation | SDK pipeline | Enable the SDK publish pipeline (#404)
1 parent bf36219 commit 1a7974d

File tree

2 files changed

+211
-0
lines changed

2 files changed

+211
-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: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Publish
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
10+
outputs:
11+
release_number: ${{steps.get_latest_release_number.outputs.release_tag}}
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
steps:
17+
- name: Checkout Xero-Java repo
18+
uses: actions/checkout@v4
19+
with:
20+
repository: XeroAPI/Xero-Java
21+
path: Xero-Java
22+
23+
- name: Set up JDK environment
24+
uses: actions/setup-java@v4
25+
with:
26+
distribution: 'temurin'
27+
java-version: '11'
28+
cache: maven
29+
server-id: ossrh
30+
server-username: MAVEN_USERNAME
31+
server-password: MAVEN_PASSWORD
32+
gpg-passphrase: GPG_PASSPHRASE
33+
34+
- name: Fetch Latest release number
35+
id: get_latest_release_number
36+
run: |
37+
latest_version=$(gh release view --json tagName --jq '.tagName')
38+
echo "Latest release version is - $latest_version"
39+
echo "::set-output name=release_tag::$latest_version"
40+
working-directory: Xero-Java
41+
env:
42+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
43+
44+
- name: Import GPG Key
45+
run: |
46+
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
47+
env:
48+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY}}
49+
50+
- name: Publish to Maven
51+
run: |
52+
export GPG_TTY=$(tty)
53+
mvn clean deploy -DskipTests=true
54+
env:
55+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
56+
MAVEN_PASSWORD: ${{ secrets.MAVEN_TOKEN }}
57+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
58+
working-directory: Xero-Java
59+
60+
notify-slack-on-success:
61+
runs-on: ubuntu-latest
62+
needs: publish
63+
if: success()
64+
permissions:
65+
contents: read
66+
steps:
67+
- name: Checkout Xero-Java repo
68+
uses: actions/checkout@v4
69+
with:
70+
repository: XeroAPI/Xero-Java
71+
path: Xero-Java
72+
73+
- name: Send slack notification on success
74+
uses: ./Xero-Java/.github/actions/notify-slack
75+
with:
76+
heading_text: "Publish job has succeeded !"
77+
alert_type: "thumbsup"
78+
job_status: "Success"
79+
XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}}
80+
job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
81+
button_type: "primary"
82+
package_version: ${{needs.publish.outputs.release_number}}
83+
repo_link: ${{github.server_url}}/${{github.repository}}
84+
85+
notify-slack-on-failure:
86+
runs-on: ubuntu-latest
87+
needs: publish
88+
if: failure()
89+
permissions:
90+
contents: read
91+
steps:
92+
- name: Checkout Xero-Java repo
93+
uses: actions/checkout@v4
94+
with:
95+
repository: XeroAPI/Xero-Java
96+
path: Xero-Java
97+
98+
- name: Send slack notification on failure
99+
uses: ./Xero-Java/.github/actions/notify-slack
100+
with:
101+
heading_text: "Publish job has failed !"
102+
alert_type: "alert"
103+
job_status: "Failed"
104+
XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}}
105+
job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
106+
button_type: "danger"
107+
package_version: ${{needs.publish.outputs.release_number}}
108+
repo_link: ${{github.server_url}}/${{github.repository}}

0 commit comments

Comments
 (0)