Compare commits
No commits in common. "main" and "v0.1.1" have entirely different histories.
18 changed files with 293 additions and 509 deletions
|
|
@ -1,5 +0,0 @@
|
||||||
.github
|
|
||||||
.gitignore
|
|
||||||
action.yml
|
|
||||||
docker-slimbuild
|
|
||||||
main_test.go
|
|
||||||
44
.github/workflows/example.yml
vendored
44
.github/workflows/example.yml
vendored
|
|
@ -1,41 +1,29 @@
|
||||||
name: Sample Testing
|
name: Sample Testing
|
||||||
on: [workflow_dispatch]
|
on: [push]
|
||||||
|
|
||||||
env:
|
|
||||||
VER: 0.3.1
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
my_job:
|
my_job:
|
||||||
runs-on: stackit-docker
|
runs-on: stackit-docker
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: First Chat Message
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Get commit hash
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v${{ env.VER }}
|
run: echo "::set-output name=sha8::$(echo ${FORGEJO_SHA} | cut -c1-8)"
|
||||||
|
id: slug
|
||||||
|
|
||||||
|
- name: Chat Setup
|
||||||
|
if: ${{ always() }}
|
||||||
|
uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v0.1.1
|
||||||
with:
|
with:
|
||||||
title: "[START] sample test (${{ forgejo.run_number }})"
|
|
||||||
author: ${{ forgejo.actor }}
|
|
||||||
giturl: ${{ forgejo.server_url }}
|
|
||||||
iconslug: instacart
|
|
||||||
# status: ${{ job.status }} # optional
|
|
||||||
actionid: ${{ forgejo.run_number }}
|
|
||||||
webhook: "${{ secrets.WEBHOOK_URL }}"
|
|
||||||
# event_body: "" # optional
|
|
||||||
|
|
||||||
# - name: Force failure
|
|
||||||
# run: |
|
|
||||||
# echo "This is a force failure"
|
|
||||||
# exit 1
|
|
||||||
|
|
||||||
- name: Second Chat Message as ThreadResponse
|
|
||||||
if: ${{ always() }}
|
|
||||||
uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v0.1.2
|
|
||||||
with:
|
|
||||||
title: "[END] sample test (${{ forgejo.run_number }})"
|
|
||||||
iconslug: bun
|
|
||||||
author: ${{ forgejo.actor }}
|
author: ${{ forgejo.actor }}
|
||||||
giturl: ${{ forgejo.server_url }}
|
giturl: ${{ forgejo.server_url }}
|
||||||
|
project: ${{ forgejo.repository }}
|
||||||
|
commit: ${{ steps.slug.outputs.sha8 }}
|
||||||
|
branch: ${{ forgejo.ref }}
|
||||||
status: ${{ job.status }}
|
status: ${{ job.status }}
|
||||||
actionid: ${{ forgejo.run_number }}
|
actionid: ${{ forgejo.run_id }}
|
||||||
webhook: "${{ secrets.WEBHOOK_URL }}"
|
webhook: "${{ secrets.WEBHOOK_URL }}"
|
||||||
event_body: "this time <b>I</b> provided a body"
|
event_body: ""
|
||||||
|
|
|
||||||
143
.github/workflows/release.yml
vendored
143
.github/workflows/release.yml
vendored
|
|
@ -1,143 +0,0 @@
|
||||||
name: CI
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- '**'
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- '**'
|
|
||||||
|
|
||||||
env:
|
|
||||||
VER: 0.3.1
|
|
||||||
|
|
||||||
# If a 403 error occurs, make sure to set content permission to write
|
|
||||||
# see: https://github.com/go-semantic-release/action/issues/27
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
runs-on: stackit-docker
|
|
||||||
steps:
|
|
||||||
- name: CI checkout
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Setup GO
|
|
||||||
uses: actions/setup-go@v6
|
|
||||||
with:
|
|
||||||
# go-version: 1.26
|
|
||||||
go-version-file: 'go.mod'
|
|
||||||
cache-dependency-path: 'go.sum'
|
|
||||||
|
|
||||||
- name: GO Linting
|
|
||||||
uses: golangci/golangci-lint-action@v9
|
|
||||||
with:
|
|
||||||
version: v2.11
|
|
||||||
|
|
||||||
# build:
|
|
||||||
# runs-on: stackit-docker
|
|
||||||
## strategy:
|
|
||||||
## fail-fast: true
|
|
||||||
## matrix:
|
|
||||||
## node: [10, 12]
|
|
||||||
# steps:
|
|
||||||
# - uses: actions/checkout@v6
|
|
||||||
#
|
|
||||||
# - uses: actions/setup-node@v1
|
|
||||||
# with:
|
|
||||||
# node-version: ${{ matrix.node }}
|
|
||||||
# - run: npm ci
|
|
||||||
# - run: npm test
|
|
||||||
release:
|
|
||||||
runs-on: stackit-docker
|
|
||||||
# needs: build
|
|
||||||
outputs:
|
|
||||||
tag: ${{ steps.create_release.outputs.tag }}
|
|
||||||
steps:
|
|
||||||
- name: "đź–… [START] release workflow"
|
|
||||||
if: ${{ always() }}
|
|
||||||
uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v${{ env.VER }}
|
|
||||||
with:
|
|
||||||
title: "[START] release workflow (${{ forgejo.run_number }})"
|
|
||||||
subtitle: "${{ forgejo.repostitory }}"
|
|
||||||
author: ${{ forgejo.actor }}
|
|
||||||
giturl: ${{ forgejo.server_url }}
|
|
||||||
iconslug: instacart
|
|
||||||
actionid: ${{ forgejo.run_number }}
|
|
||||||
webhook: "${{ secrets.WEBHOOK_URL }}"
|
|
||||||
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
# - name: Semantic Release
|
|
||||||
# uses: go-semantic-release/action@v1
|
|
||||||
# id: semrel
|
|
||||||
# with:
|
|
||||||
# github-token: ${{ env.FORGEJO_TOKEN }}
|
|
||||||
# allow-initial-development-versions: true
|
|
||||||
# # update-file: package.json
|
|
||||||
# changelog-file: CHANGELOG.md
|
|
||||||
# changelog-generator-opt: "emojis=true"
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
env:
|
|
||||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
|
||||||
id: create_release
|
|
||||||
run: |
|
|
||||||
npx \
|
|
||||||
-p semantic-release \
|
|
||||||
-p semantic-release-replace-plugin \
|
|
||||||
-p @semantic-release/commit-analyzer \
|
|
||||||
-p @semantic-release/release-notes-generator \
|
|
||||||
-p @semantic-release/changelog \
|
|
||||||
-p @semantic-release/git \
|
|
||||||
semantic-release
|
|
||||||
echo "tag=$(git describe --tags --abbrev=0)" >> $FORGEJO_OUTPUT
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
if: steps.create_release.outputs.tag != ''
|
|
||||||
uses: docker/login-action@v4
|
|
||||||
with:
|
|
||||||
registry: ${{ forgejo.server_url }}
|
|
||||||
username: ${{ vars.GIT_USERNAME }}
|
|
||||||
password: ${{ secrets.GIT_PAT }}
|
|
||||||
|
|
||||||
# - name: Set up QEMU
|
|
||||||
# if: steps.semrel.outputs.version != ''
|
|
||||||
# uses: docker/setup-qemu-action@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
if: steps.create_release.outputs.tag != ''
|
|
||||||
uses: docker/setup-buildx-action@v4
|
|
||||||
|
|
||||||
- name: Build only
|
|
||||||
if: steps.create_release.outputs.tag == ''
|
|
||||||
uses: docker/build-push-action@v7
|
|
||||||
with:
|
|
||||||
push: false
|
|
||||||
tags: actions/notify-slim:dev
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
if: steps.create_release.outputs.tag != ''
|
|
||||||
uses: docker/build-push-action@v7
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
tags: stackit-solutions.git.onstackit.cloud/actions/notify-slim:${{ steps.create_release.outputs.tag }}
|
|
||||||
|
|
||||||
- name: "đź–… [END] release workflow"
|
|
||||||
if: ${{ always() }}
|
|
||||||
uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v${{ env.VER }}
|
|
||||||
with:
|
|
||||||
title: "[END] release workflow (${{ forgejo.run_number }})"
|
|
||||||
subtitle: "${{ forgejo.repostitory }}"
|
|
||||||
author: ${{ forgejo.actor }}
|
|
||||||
giturl: ${{ forgejo.server_url }}
|
|
||||||
iconslug: instacart
|
|
||||||
actionid: ${{ forgejo.run_number }}
|
|
||||||
webhook: "${{ secrets.WEBHOOK_URL }}"
|
|
||||||
status: 'completed'
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
version: "2"
|
|
||||||
run:
|
|
||||||
concurrency: 4
|
|
||||||
output:
|
|
||||||
formats:
|
|
||||||
text:
|
|
||||||
print-linter-name: true
|
|
||||||
print-issued-lines: true
|
|
||||||
colors: true
|
|
||||||
path: stdout
|
|
||||||
linters:
|
|
||||||
enable:
|
|
||||||
- bodyclose
|
|
||||||
- depguard
|
|
||||||
- errorlint
|
|
||||||
- forcetypeassert
|
|
||||||
- gochecknoinits
|
|
||||||
- gocritic
|
|
||||||
- gosec
|
|
||||||
- misspell
|
|
||||||
- nakedret
|
|
||||||
- revive
|
|
||||||
- sqlclosecheck
|
|
||||||
- wastedassign
|
|
||||||
disable:
|
|
||||||
- noctx
|
|
||||||
- unparam
|
|
||||||
settings:
|
|
||||||
depguard:
|
|
||||||
rules:
|
|
||||||
main:
|
|
||||||
list-mode: original
|
|
||||||
allow: []
|
|
||||||
deny:
|
|
||||||
- pkg: github.com/stretchr/testify
|
|
||||||
desc: Do not use a testing framework
|
|
||||||
gocritic:
|
|
||||||
disabled-checks:
|
|
||||||
- wrapperFunc
|
|
||||||
- typeDefFirst
|
|
||||||
- ifElseChain
|
|
||||||
- dupImport
|
|
||||||
- hugeParam
|
|
||||||
enabled-tags:
|
|
||||||
- performance
|
|
||||||
- style
|
|
||||||
- experimental
|
|
||||||
gosec:
|
|
||||||
excludes:
|
|
||||||
- G104
|
|
||||||
- G102
|
|
||||||
- G304
|
|
||||||
- G307
|
|
||||||
misspell:
|
|
||||||
locale: US
|
|
||||||
nakedret:
|
|
||||||
max-func-lines: 0
|
|
||||||
revive:
|
|
||||||
severity: error
|
|
||||||
rules:
|
|
||||||
- name: errorf
|
|
||||||
- name: context-as-argument
|
|
||||||
- name: error-return
|
|
||||||
- name: increment-decrement
|
|
||||||
- name: indent-error-flow
|
|
||||||
- name: superfluous-else
|
|
||||||
- name: unused-parameter
|
|
||||||
- name: unreachable-code
|
|
||||||
- name: atomic
|
|
||||||
- name: empty-lines
|
|
||||||
- name: early-return
|
|
||||||
exclusions:
|
|
||||||
paths: []
|
|
||||||
generated: lax
|
|
||||||
warn-unused: true
|
|
||||||
# Excluding configuration per-path, per-linter, per-text and per-source.
|
|
||||||
rules:
|
|
||||||
# Exclude some linters from running on tests files.
|
|
||||||
- path: _test\.go
|
|
||||||
linters:
|
|
||||||
- gochecknoinits
|
|
||||||
formatters:
|
|
||||||
enable:
|
|
||||||
- gofmt
|
|
||||||
- goimports
|
|
||||||
# settings:
|
|
||||||
# goimports:
|
|
||||||
# local-prefixes:
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
||||||
{
|
|
||||||
"branches": ["main"],
|
|
||||||
"tagFormat": "v${version}",
|
|
||||||
"plugins": [
|
|
||||||
"@semantic-release/commit-analyzer",
|
|
||||||
[
|
|
||||||
"semantic-release-replace-plugin",
|
|
||||||
{
|
|
||||||
"replacements": [
|
|
||||||
{
|
|
||||||
"files": ["action.yml"],
|
|
||||||
"from": " image: 'docker://stackit-solutions.git.onstackit.cloud/actions/notify-slim:v.*'",
|
|
||||||
"to": " image: 'docker://stackit-solutions.git.onstackit.cloud/actions/notify-slim:v${nextRelease.version}'",
|
|
||||||
"results": [
|
|
||||||
{
|
|
||||||
"file": "action.yml",
|
|
||||||
"hasChanged": true,
|
|
||||||
"numMatches": 1,
|
|
||||||
"numReplacements": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"countMatches": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"files": ["README.md"],
|
|
||||||
"from": " uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v.*",
|
|
||||||
"to": " uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v${nextRelease.version}",
|
|
||||||
"results": [
|
|
||||||
{
|
|
||||||
"file": "README.md",
|
|
||||||
"hasChanged": true,
|
|
||||||
"numMatches": 1,
|
|
||||||
"numReplacements": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"countMatches": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"files": [".github/workflows/example.yml"],
|
|
||||||
"from": " VER: .*",
|
|
||||||
"to": " VER: ${nextRelease.version}",
|
|
||||||
"results": [
|
|
||||||
{
|
|
||||||
"file": ".github/workflows/example.yml",
|
|
||||||
"hasChanged": true,
|
|
||||||
"numMatches": 1,
|
|
||||||
"numReplacements": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"countMatches": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"files": [".github/workflows/release.yml"],
|
|
||||||
"from": " VER: .*",
|
|
||||||
"to": " VER: ${nextRelease.version}",
|
|
||||||
"results": [
|
|
||||||
{
|
|
||||||
"file": ".github/workflows/release.yml",
|
|
||||||
"hasChanged": true,
|
|
||||||
"numMatches": 1,
|
|
||||||
"numReplacements": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"countMatches": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"@semantic-release/release-notes-generator",
|
|
||||||
"@semantic-release/changelog",
|
|
||||||
[
|
|
||||||
"@semantic-release/git",
|
|
||||||
{
|
|
||||||
"assets": ["CHANGELOG.md", "README.md", "action.yml", ".github/workflows/example.yml", ".github/workflows/release.yml"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
23
CHANGELOG.md
23
CHANGELOG.md
|
|
@ -1,23 +0,0 @@
|
||||||
## [0.3.1](https://stackit-solutions.git.onstackit.cloud/actions/notify/compare/v0.3.0...v0.3.1) (2026-04-17)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* pipeline fixes ([b195a1d](https://stackit-solutions.git.onstackit.cloud/actions/notify/commit/b195a1dcfdd7bf98eaaeb976d08260a2457da317))
|
|
||||||
|
|
||||||
# [0.3.0](https://stackit-solutions.git.onstackit.cloud/actions/notify/compare/v0.2.0...v0.3.0) (2026-04-17)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* linting ([68c1f11](https://stackit-solutions.git.onstackit.cloud/actions/notify/commit/68c1f11a5cc02918166ca05e4af79712a5c0964b))
|
|
||||||
* linting ([16a5f87](https://stackit-solutions.git.onstackit.cloud/actions/notify/commit/16a5f874b341a6d4776dbe5e46be391f1d6576d8))
|
|
||||||
|
|
||||||
# [0.2.0](https://stackit-solutions.git.onstackit.cloud/actions/notify/compare/v0.1.2...v0.2.0) (2026-04-17)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* linting ([9d4e8c9](https://stackit-solutions.git.onstackit.cloud/actions/notify/commit/9d4e8c9a9dc3fcc133299e978fed191ad6052aac))
|
|
||||||
* linting ([5b93809](https://stackit-solutions.git.onstackit.cloud/actions/notify/commit/5b938091d705e01f6467cdd6be9144e491c66502))
|
|
||||||
* pipeline container build ([0414cf6](https://stackit-solutions.git.onstackit.cloud/actions/notify/commit/0414cf6dfb9956c85bb48f5217806841f5819716))
|
|
||||||
27
Dockerfile
27
Dockerfile
|
|
@ -1,29 +1,8 @@
|
||||||
FROM golang:1.26 AS builder
|
FROM golang:1.26
|
||||||
|
|
||||||
RUN apt-get update && apt-get -y install upx
|
WORKDIR /src
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
ENV CGO_ENABLED=0
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN go mod tidy && go build \
|
RUN go get -u github.com/sethvargo/go-githubactions/... && go build -o /bin/google-chat-action
|
||||||
-a \
|
|
||||||
-trimpath \
|
|
||||||
-ldflags "-s -w -extldflags '-static'" \
|
|
||||||
-installsuffix cgo \
|
|
||||||
-tags netgo \
|
|
||||||
-o /bin/google-chat-action \
|
|
||||||
.
|
|
||||||
|
|
||||||
RUN strip /bin/google-chat-action
|
|
||||||
|
|
||||||
RUN upx -q -9 /bin/google-chat-action
|
|
||||||
|
|
||||||
FROM scratch
|
|
||||||
|
|
||||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
|
||||||
|
|
||||||
COPY --from=builder /bin/google-chat-action /bin/google-chat-action
|
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/google-chat-action"]
|
ENTRYPOINT ["/bin/google-chat-action"]
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
FROM golang:1.26
|
|
||||||
|
|
||||||
WORKDIR /src
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN go get -u github.com/sethvargo/go-githubactions/... \
|
|
||||||
&& go mod tidy \
|
|
||||||
&& go build -o /bin/google-chat-action
|
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/google-chat-action"]
|
|
||||||
31
README.md
31
README.md
|
|
@ -13,20 +13,23 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# ... all your steps
|
- name: Checkout
|
||||||
- name: Sample Chat Message
|
uses: actions/checkout@v6
|
||||||
if: ${{ always() }} # runs als after fails
|
|
||||||
uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v0.3.1
|
- name: Get commit hash
|
||||||
|
if: ${{ always() }}
|
||||||
|
run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
|
||||||
|
id: slug
|
||||||
|
|
||||||
|
- name: Chat Setup
|
||||||
|
if: ${{ always() }}
|
||||||
|
uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v0
|
||||||
with:
|
with:
|
||||||
title: "[START] sample test (${{ forgejo.run_number }})"
|
project: ${{ github.repository }}
|
||||||
author: ${{ forgejo.actor }}
|
commit: ${{ steps.slug.outputs.sha8 }}
|
||||||
giturl: ${{ forgejo.server_url }}
|
branch: ${{ github.ref }}
|
||||||
iconslug: instacart # optional
|
status: ${{ job.status }}
|
||||||
# status: ${{ job.status }} # optional
|
actionid: ${{ github.repository }}/runs/${{ github.run_id }}
|
||||||
actionid: ${{ forgejo.run_number }}
|
webhook: "https://chat.googleapis.com/v1/spaces/AAAAzPcAy4s/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=MmdzluicdrdkyUAV_QwB6BzlLcIhbfrwNzxVrEllaec%3D&threadKey=git-commit"
|
||||||
webhook: "${{ secrets.WEBHOOK_URL }}"
|
|
||||||
event_body: "This is a sample <b>TEXT</b><br>with a new line" # optional
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
TODO - icon_slug
|
|
||||||
|
|
|
||||||
29
action.yml
29
action.yml
|
|
@ -1,18 +1,21 @@
|
||||||
name: 'Google Chat Action'
|
name: 'Google Chat Action'
|
||||||
author: 'D Ther Htun/ Marcel S. Henselin'
|
author: 'D Ther Htun'
|
||||||
description: 'Github actions for google chat Room Bot'
|
description: 'Github actions for google chat Room Bot'
|
||||||
branding:
|
branding:
|
||||||
icon: 'at-sign'
|
icon: 'at-sign'
|
||||||
color: 'green'
|
color: 'green'
|
||||||
inputs:
|
inputs:
|
||||||
autor:
|
project:
|
||||||
description: 'Git Action Author'
|
description: 'Github Project Name'
|
||||||
required: true
|
required: true
|
||||||
giturl:
|
commit:
|
||||||
description: 'Git Server URL'
|
description: 'Github Commit ID'
|
||||||
|
required: true
|
||||||
|
branch:
|
||||||
|
description: 'Github Branch'
|
||||||
required: true
|
required: true
|
||||||
status:
|
status:
|
||||||
description: 'Git Action Build Status'
|
description: 'Github Action Build Status'
|
||||||
required: true
|
required: true
|
||||||
actionid:
|
actionid:
|
||||||
description: 'Current Running Action ID'
|
description: 'Current Running Action ID'
|
||||||
|
|
@ -20,14 +23,18 @@ inputs:
|
||||||
webhook:
|
webhook:
|
||||||
description: 'Google Chat Webhook URL'
|
description: 'Google Chat Webhook URL'
|
||||||
required: true
|
required: true
|
||||||
event_body:
|
|
||||||
description: 'Google Chat Event Body'
|
|
||||||
required: true
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: 'docker://stackit-solutions.git.onstackit.cloud/actions/notify-slim:v0.1.2'
|
# using: 'composite'
|
||||||
# image: 'Dockerfile'
|
# steps:
|
||||||
|
# - name: 'Run Google Chat Action'
|
||||||
|
# shell: bash
|
||||||
|
# run: |
|
||||||
|
# docker run --rm -it $(docker build -q .)
|
||||||
|
|
||||||
|
#image: 'docker://dther/google-chat-action:v0.8'
|
||||||
|
image: 'Dockerfile'
|
||||||
args:
|
args:
|
||||||
- ${{ inputs.project }}
|
- ${{ inputs.project }}
|
||||||
- ${{ inputs.commit }}
|
- ${{ inputs.commit }}
|
||||||
|
|
|
||||||
30
docker-slimbuild
Normal file
30
docker-slimbuild
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
FROM golang:1.13 AS builder
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get -y install upx
|
||||||
|
|
||||||
|
#RUN mkdir -p $GOPATH/src/github.com/DTherHtun/google-chat-action
|
||||||
|
#ADD . $GOPATH/src/github.com/DTherHtun/google-chat-action
|
||||||
|
RUN go get -u github.com/sethvargo/go-githubactions/...
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN go build \
|
||||||
|
-a \
|
||||||
|
-trimpath \
|
||||||
|
-ldflags "-s -w -extldflags '-static'" \
|
||||||
|
-installsuffix cgo \
|
||||||
|
-tags netgo \
|
||||||
|
-o /bin/google-chat-action \
|
||||||
|
.
|
||||||
|
|
||||||
|
RUN strip /bin/google-chat-action
|
||||||
|
|
||||||
|
RUN upx -q -9 /bin/google-chat-action
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
|
||||||
|
COPY --from=builder /bin/google-chat-action /bin/google-chat-action
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/google-chat-action"]
|
||||||
6
go.sum
6
go.sum
|
|
@ -1,6 +0,0 @@
|
||||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
|
||||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
|
||||||
github.com/sethvargo/go-githubactions v1.3.2 h1:gkibLr/QjosgNWoCf1V58rTMRZw7xZtSB7dY4atbl1Y=
|
|
||||||
github.com/sethvargo/go-githubactions v1.3.2/go.mod h1:7/4WeHgYfSz9U5vwuToCK9KPnELVHAhGtRwLREOQV80=
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 48 KiB |
156
main.go
156
main.go
|
|
@ -18,20 +18,21 @@ const (
|
||||||
failedColor = "8b0000/dc143c"
|
failedColor = "8b0000/dc143c"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed message.tpl
|
//go:embed message_old.tpl
|
||||||
var message string
|
var message string
|
||||||
|
|
||||||
type templateData struct {
|
type templateData struct {
|
||||||
CardID string
|
CardID string
|
||||||
IconSlug string
|
|
||||||
Title string
|
Title string
|
||||||
SubTitle string
|
SubTitle string
|
||||||
Author string
|
Author string
|
||||||
IconUrl string
|
IconUrl string
|
||||||
|
Project string
|
||||||
|
Commit string
|
||||||
|
Branch string
|
||||||
Status string
|
Status string
|
||||||
ActionID string
|
ActionID string
|
||||||
GitURL string
|
GitURL string
|
||||||
Project string
|
|
||||||
Color string
|
Color string
|
||||||
Add string
|
Add string
|
||||||
EventBody string
|
EventBody string
|
||||||
|
|
@ -42,14 +43,61 @@ func main() {
|
||||||
data.CardID = uuid.NewString()
|
data.CardID = uuid.NewString()
|
||||||
data.Add = ""
|
data.Add = ""
|
||||||
|
|
||||||
getData(&data)
|
author := githubactions.GetInput("author")
|
||||||
|
if author == "" {
|
||||||
|
githubactions.Infof("[INFO] Missing input 'author', using default")
|
||||||
|
author = "STACKIT git action"
|
||||||
|
}
|
||||||
|
data.Author = author
|
||||||
|
|
||||||
|
title := githubactions.GetInput("title")
|
||||||
|
if title == "" {
|
||||||
|
githubactions.Infof("[INFO] Missing input 'title', using default")
|
||||||
|
title = "STACKIT git action"
|
||||||
|
}
|
||||||
|
data.Title = title
|
||||||
|
|
||||||
|
project := githubactions.GetInput("project")
|
||||||
|
if project == "" {
|
||||||
|
githubactions.Fatalf("Missing input 'project'")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
data.Project = project
|
||||||
|
|
||||||
|
commit := githubactions.GetInput("commit")
|
||||||
|
if commit == "" {
|
||||||
|
githubactions.Fatalf("Missing input 'commit'")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
data.Commit = commit
|
||||||
|
|
||||||
|
branch := githubactions.GetInput("branch")
|
||||||
|
if branch == "" {
|
||||||
|
githubactions.Fatalf("Missing input 'branch'")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
data.Branch = branch
|
||||||
|
|
||||||
|
status := githubactions.GetInput("status")
|
||||||
|
if status == "" {
|
||||||
|
githubactions.Fatalf("Missing input 'status'")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
data.Status = status
|
||||||
|
|
||||||
|
actionid := githubactions.GetInput("actionid")
|
||||||
|
if actionid == "" {
|
||||||
|
githubactions.Fatalf("Missing input 'actionid'")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
data.ActionID = actionid
|
||||||
|
|
||||||
webhook := githubactions.GetInput("webhook")
|
webhook := githubactions.GetInput("webhook")
|
||||||
if webhook == "" {
|
if webhook == "" {
|
||||||
githubactions.Fatalf("Missing input 'webhook'")
|
githubactions.Fatalf("Missing input 'webhook'")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
webhook = fmt.Sprintf("%s&threadKey=notify%s&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD", webhook, data.ActionID)
|
webhook = fmt.Sprintf("%s&threadKey=%s%s&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD", webhook, data.Commit, data.ActionID)
|
||||||
|
|
||||||
giturl := githubactions.GetInput("giturl")
|
giturl := githubactions.GetInput("giturl")
|
||||||
if giturl == "" {
|
if giturl == "" {
|
||||||
|
|
@ -62,13 +110,18 @@ func main() {
|
||||||
data.EventBody = body
|
data.EventBody = body
|
||||||
|
|
||||||
githubactions.Infof("using URL: %s", webhook)
|
githubactions.Infof("using URL: %s", webhook)
|
||||||
|
// fmt.Println("URL:> ", webhook)
|
||||||
|
|
||||||
|
// var jsonStr = []byte(fmt.Sprintf(data, project, commit, branch, status, actionid))
|
||||||
|
|
||||||
jsonStr, err := card(data)
|
jsonStr, err := card(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
githubactions.Fatalf("err %s", err.Error())
|
githubactions.Fatalf("error %s", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// log.Printf("retrieved data: %s", string(jsonStr))
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr))
|
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
githubactions.Fatalf("error %s", err.Error())
|
githubactions.Fatalf("error %s", err.Error())
|
||||||
|
|
@ -81,8 +134,7 @@ func main() {
|
||||||
githubactions.Fatalf("error %s", err.Error())
|
githubactions.Fatalf("error %s", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close() //nolint:gocritic
|
defer resp.Body.Close()
|
||||||
|
|
||||||
fmt.Println("response Status:", resp.Status)
|
fmt.Println("response Status:", resp.Status)
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
githubactions.Infof("json: %s", jsonStr)
|
githubactions.Infof("json: %s", jsonStr)
|
||||||
|
|
@ -91,51 +143,6 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getData(data *templateData) {
|
|
||||||
prj, ok := os.LookupEnv("FORGEJO_REPOSITORY")
|
|
||||||
if ok {
|
|
||||||
data.Project = prj
|
|
||||||
}
|
|
||||||
|
|
||||||
author := githubactions.GetInput("author")
|
|
||||||
if author == "" {
|
|
||||||
githubactions.Infof("[INFO] Missing input 'author', using default")
|
|
||||||
author = "STACKIT git action"
|
|
||||||
}
|
|
||||||
data.Author = author
|
|
||||||
|
|
||||||
icon := githubactions.GetInput("iconslug")
|
|
||||||
if icon == "" {
|
|
||||||
githubactions.Infof("[INFO] Missing input 'iconslug', using default")
|
|
||||||
icon = "git"
|
|
||||||
}
|
|
||||||
data.IconSlug = icon
|
|
||||||
|
|
||||||
title := githubactions.GetInput("title")
|
|
||||||
if title == "" {
|
|
||||||
githubactions.Infof("[INFO] Missing input 'title', using default")
|
|
||||||
title = "STACKIT git action"
|
|
||||||
}
|
|
||||||
data.Title = title
|
|
||||||
|
|
||||||
status := githubactions.GetInput("status")
|
|
||||||
if status == "" {
|
|
||||||
githubactions.Infof("[INFO] Missing input 'status', trying default")
|
|
||||||
var ok bool
|
|
||||||
if status, ok = os.LookupEnv("JOB_STATUS"); ok {
|
|
||||||
githubactions.Infof("[INFO] found job status")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data.Status = status
|
|
||||||
|
|
||||||
actionid := githubactions.GetInput("actionid")
|
|
||||||
if actionid == "" {
|
|
||||||
githubactions.Fatalf("Missing input 'actionid'")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
data.ActionID = actionid
|
|
||||||
}
|
|
||||||
|
|
||||||
func card(d templateData) ([]byte, error) {
|
func card(d templateData) ([]byte, error) {
|
||||||
switch d.Status {
|
switch d.Status {
|
||||||
case "success":
|
case "success":
|
||||||
|
|
@ -147,34 +154,39 @@ func card(d templateData) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.IconUrl == "" {
|
if d.IconUrl == "" {
|
||||||
d.IconUrl = fmt.Sprintf(
|
d.IconUrl = "https://github.githubassets.com/images/modules/logos_page/Octocat.png"
|
||||||
"https://cdn.simpleicons.org/%s/%s",
|
|
||||||
d.IconSlug,
|
|
||||||
d.Color,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.EventBody == "" {
|
if d.EventBody == "" {
|
||||||
bdy := ""
|
d.EventBody = "<b>Project:</b> {{ .Project }}<br><b>Commit-id:</b> <font color=\"#FF0000\">{{ .Commit }}</font><br><b>Branch:</b> <font color=\"#00FF00f\">{{ .Branch }}</font><br><b>Build Status:</b> <font color=\"#0000ff\">{{ .Status }}</font>"
|
||||||
if d.Project != "" {
|
|
||||||
bdy += fmt.Sprintf("<b>Project:</b> %s<br>", d.Project)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sha, ok := os.LookupEnv("FORGEJO_SHA")
|
if d.Status == "success" {
|
||||||
if ok {
|
d.Add = `
|
||||||
bdy += fmt.Sprintf("<b>Commit-id:</b> <font color='#FF0000'> %.*s</font><br>", 8, sha)
|
{
|
||||||
|
"decoratedText": {
|
||||||
|
"startIcon": {
|
||||||
|
"materialIcon": {
|
||||||
|
"name": "check_circle"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"text": "<b style=\"color: green;\">SUCCESS</b>"
|
||||||
|
}
|
||||||
|
},`
|
||||||
}
|
}
|
||||||
|
|
||||||
ref, ok := os.LookupEnv("FORGEJO_REF")
|
if d.Status == "failure" {
|
||||||
if ok {
|
d.Add = `
|
||||||
bdy += fmt.Sprintf("<b>Branch:</b> <font color='#00FF00f'>%s</font><br>", ref)
|
{
|
||||||
|
"decoratedText": {
|
||||||
|
"startIcon": {
|
||||||
|
"materialIcon": {
|
||||||
|
"name": "stop_circle"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
if d.Status != "" {
|
"text": "<b style=\"color: red;\">FAILURE</b>"
|
||||||
bdy += fmt.Sprintf("<b>Build Status:</b> <font color='#0000ff'>%s</font>", d.Status)
|
|
||||||
}
|
}
|
||||||
|
},`
|
||||||
d.EventBody = bdy
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.New("message").Parse(message)
|
tmpl, err := template.New("message").Parse(message)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ func Test_card(t *testing.T) {
|
||||||
Author: "gotest",
|
Author: "gotest",
|
||||||
IconUrl: "https://github.githubassets.com/images/modules/logos_page/Octocat.png",
|
IconUrl: "https://github.githubassets.com/images/modules/logos_page/Octocat.png",
|
||||||
Project: "proj",
|
Project: "proj",
|
||||||
|
Commit: "12345",
|
||||||
|
Branch: "main",
|
||||||
Status: "success",
|
Status: "success",
|
||||||
ActionID: "123",
|
ActionID: "123",
|
||||||
GitURL: "https://test.url",
|
GitURL: "https://test.url",
|
||||||
|
|
@ -113,6 +115,9 @@ func Test_card(t *testing.T) {
|
||||||
t.Fatalf("error: %v\nsrc: %s", err, tt.want)
|
t.Fatalf("error: %v\nsrc: %s", err, tt.want)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if !reflect.DeepEqual(wantJson, gotJson) {
|
||||||
|
// t.Errorf("card() got = %v, want %v", gotJson, wantJson)
|
||||||
|
//}
|
||||||
if diff := cmp.Diff(wantJson, gotJson); diff != "" {
|
if diff := cmp.Diff(wantJson, gotJson); diff != "" {
|
||||||
t.Errorf("MakeGatewayInfo() mismatch (-want +got):\n%s", diff)
|
t.Errorf("MakeGatewayInfo() mismatch (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
"sections": [
|
"sections": [
|
||||||
{
|
{
|
||||||
"header": "{{ .Title }}",
|
"header": "{{ .Title }}",
|
||||||
"collapsible": false,
|
"collapsible": true,
|
||||||
"uncollapsibleWidgetsCount": 2,
|
"uncollapsibleWidgetsCount": 2,
|
||||||
"widgets": [
|
"widgets": [
|
||||||
{
|
{
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
{
|
{
|
||||||
"textParagraph": {
|
"textParagraph": {
|
||||||
"text": "{{ .EventBody }}",
|
"text": "{{ .EventBody }}",
|
||||||
"maxLines": 5
|
"maxLines": 2
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
35
message_old.tpl
Normal file
35
message_old.tpl
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"header": {
|
||||||
|
"title": "{{ .Title }}",
|
||||||
|
"subtitle": "{{ .SubTitle }}",
|
||||||
|
"imageUrl": "{{ .IconUrl }}",
|
||||||
|
"imageStyle": "IMAGE"
|
||||||
|
},
|
||||||
|
"sections": [
|
||||||
|
{
|
||||||
|
"widgets": [
|
||||||
|
{
|
||||||
|
"textParagraph": {
|
||||||
|
"text": "<b>Project:</b> {{ .Project }}<br><b>Commit-id:</b> <font color=\"#FF0000\">{{ .Commit }}</font><br><b>Branch:</b> <font color=\"#00FF00f\">{{ .Branch }}</font><br><b>Build Status:</b> <font color=\"#0000ff\">{{ .Status }}</font>"
|
||||||
|
},
|
||||||
|
"buttons": [
|
||||||
|
{
|
||||||
|
"textButton": {
|
||||||
|
"text": "Job Details",
|
||||||
|
"onClick": {
|
||||||
|
"openLink": {
|
||||||
|
"url": "{{ .GitURL }}/{{ .Project }}/actions/runs/{{ .ActionID }}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
78
sample.tpl
Normal file
78
sample.tpl
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
{
|
||||||
|
"cardsV2": [
|
||||||
|
{
|
||||||
|
"cardId": "unique-card-id",
|
||||||
|
"card": {
|
||||||
|
"header": {
|
||||||
|
"title": "Sasha",
|
||||||
|
"subtitle": "Software Engineer",
|
||||||
|
"imageUrl":
|
||||||
|
"https://developers.google.com/workspace/chat/images/quickstart-app-avatar.png",
|
||||||
|
"imageType": "CIRCLE",
|
||||||
|
"imageAltText": "Avatar for Sasha"
|
||||||
|
},
|
||||||
|
"sections": [
|
||||||
|
{
|
||||||
|
"header": "Contact Info",
|
||||||
|
"collapsible": true,
|
||||||
|
"uncollapsibleWidgetsCount": 1,
|
||||||
|
"widgets": [
|
||||||
|
{
|
||||||
|
"decoratedText": {
|
||||||
|
"startIcon": {
|
||||||
|
"knownIcon": "EMAIL"
|
||||||
|
},
|
||||||
|
"text": "sasha@example.com"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decoratedText": {
|
||||||
|
"startIcon": {
|
||||||
|
"knownIcon": "PERSON"
|
||||||
|
},
|
||||||
|
"text": "<font color=\"#80e27e\">Online</font>"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"decoratedText": {
|
||||||
|
"startIcon": {
|
||||||
|
"knownIcon": "PHONE"
|
||||||
|
},
|
||||||
|
"text": "+1 (555) 555-1234"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buttonList": {
|
||||||
|
"buttons": [
|
||||||
|
{
|
||||||
|
"text": "Share",
|
||||||
|
"onClick": {
|
||||||
|
"openLink": {
|
||||||
|
"url": "https://example.com/share"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "Edit",
|
||||||
|
"onClick": {
|
||||||
|
"action": {
|
||||||
|
"function": "goToView",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"key": "viewType",
|
||||||
|
"value": "EDIT"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue