update new version
This commit is contained in:
parent
0f1d4a1618
commit
d72cd9bd59
3 changed files with 65 additions and 9 deletions
10
.github/workflows/example.yml
vendored
10
.github/workflows/example.yml
vendored
|
|
@ -8,12 +8,14 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- run: echo ::set-output name=action_msg::someone $GITHUB_EVENT_NAME to $GITHUB_REPOSITORY - $GITHUB_REF - commitid $GITHUB_SHA
|
||||
id: txt
|
||||
- name: Chat Setup
|
||||
uses: DTherHtun/google-chat-action@v0.3
|
||||
uses: DTherHtun/google-chat-action@v0.4
|
||||
with:
|
||||
msg: ${{ steps.txt.outputs.action_msg }}
|
||||
project: ${{ github.repository }}
|
||||
commit: ${{ github.sha }}
|
||||
branch: ${{ github.ref }}
|
||||
status: ${{ job.status }}
|
||||
actionid: ${{ github.action }}
|
||||
webhook: "https://chat.googleapis.com/v1/spaces/AAAAzPcAy4s/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=MmdzluicdrdkyUAV_QwB6BzlLcIhbfrwNzxVrEllaec%3D&threadKey=git-commit"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,5 +16,9 @@ runs:
|
|||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
args:
|
||||
- ${{ inputs.msg }}
|
||||
- ${{ inputs.project }}
|
||||
- ${{ inputs.commit }}
|
||||
- ${{ inputs.branch }}
|
||||
- ${{ inputs.status }}
|
||||
- ${{ inputs.actionid }}
|
||||
- ${{ inputs.webhook }}
|
||||
|
|
|
|||
58
main.go
58
main.go
|
|
@ -9,18 +9,68 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
msg := githubactions.GetInput("msg")
|
||||
project := githubactions.GetInput("project")
|
||||
if msg == "" {
|
||||
githubactions.Fatalf("Missing input 'msg'")
|
||||
githubactions.Fatalf("Missing input 'project'")
|
||||
}
|
||||
commit := githubactions.GetInput("commit")
|
||||
if msg == "" {
|
||||
githubactions.Fatalf("Missing input 'commit'")
|
||||
}
|
||||
branch := githubactions.GetInput("branch")
|
||||
if msg == "" {
|
||||
githubactions.Fatalf("Missing input 'branch'")
|
||||
}
|
||||
status := githubactions.GetInput("status")
|
||||
if msg == "" {
|
||||
githubactions.Fatalf("Missing input 'status'")
|
||||
}
|
||||
actionid := githubactions.GetInput("actionid")
|
||||
if msg == "" {
|
||||
githubactions.Fatalf("Missing input 'actionid'")
|
||||
}
|
||||
webhook := githubactions.GetInput("webhook")
|
||||
if webhook == "" {
|
||||
githubactions.Fatalf("Missing input 'webshook'")
|
||||
}
|
||||
|
||||
fmt.Println("URL:> ", webhook)
|
||||
|
||||
var jsonStr = []byte(fmt.Sprintf("{'text' : '%s'}", msg))
|
||||
data = `{
|
||||
"cards": [
|
||||
{
|
||||
"header": {
|
||||
"title": "GitHub Action",
|
||||
"subtitle": "Build Job",
|
||||
"imageUrl": "https://github.githubassets.com/images/modules/logos_page/Octocat.png",
|
||||
"imageStyle": "IMAGE"
|
||||
},
|
||||
"sections": [
|
||||
{
|
||||
"widgets": [
|
||||
{
|
||||
"textParagraph": {
|
||||
"text": "<b>Project:</b> %s<br><b>Commit-id:</b> <font color=\"#FF0000\">%s</font><br><b>Branch:</b> <font color=\"#00FF00f\">%s</font><br><b>Build Status:</b> <font color=\"#0000ff\">%s</font>"
|
||||
},
|
||||
"buttons": [
|
||||
{
|
||||
"textButton": {
|
||||
"text": "Job Details",
|
||||
"onClick": {
|
||||
"openLink": {
|
||||
"url": "https://github.com/DTherHtun/web-app-flux/runs/%s"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}`
|
||||
var jsonStr = []byte(fmt.Sprintf(data, project, commit, branch, status, actionid ))
|
||||
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue