diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml
index 86a45ef..03f2930 100644
--- a/.github/workflows/example.yml
+++ b/.github/workflows/example.yml
@@ -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"
diff --git a/action.yml b/action.yml
index d0ef344..67ba287 100644
--- a/action.yml
+++ b/action.yml
@@ -16,5 +16,9 @@ runs:
using: 'docker'
image: 'Dockerfile'
args:
- - ${{ inputs.msg }}
+ - ${{ inputs.project }}
+ - ${{ inputs.commit }}
+ - ${{ inputs.branch }}
+ - ${{ inputs.status }}
+ - ${{ inputs.actionid }}
- ${{ inputs.webhook }}
diff --git a/main.go b/main.go
index eb7fc25..d5984f9 100644
--- a/main.go
+++ b/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": "Project: %s
Commit-id: %s
Branch: %s
Build Status: %s"
+ },
+ "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)