Compare commits
11 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45a4a7e647 | ||
|
|
c1349c7e40 | ||
|
|
bd882b6d3e | ||
|
|
a2d6cf9305 | ||
|
|
b195a1dcfd | ||
|
|
e12834bc14 | ||
|
|
6b34a9774b | ||
|
|
eb96639c17 | ||
|
|
49fa812459 | ||
|
|
68c1f11a5c | ||
|
|
16a5f874b3 |
9 changed files with 193 additions and 70 deletions
12
.github/workflows/example.yml
vendored
12
.github/workflows/example.yml
vendored
|
|
@ -1,8 +1,8 @@
|
||||||
name: Sample Testing
|
name: Sample Testing
|
||||||
on: [push]
|
on: [workflow_dispatch]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
VER: 0.1.2
|
VER: 0.3.1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
my_job:
|
my_job:
|
||||||
|
|
@ -22,10 +22,10 @@ jobs:
|
||||||
webhook: "${{ secrets.WEBHOOK_URL }}"
|
webhook: "${{ secrets.WEBHOOK_URL }}"
|
||||||
# event_body: "" # optional
|
# event_body: "" # optional
|
||||||
|
|
||||||
- name: Force failure
|
# - name: Force failure
|
||||||
run: |
|
# run: |
|
||||||
echo "This is a force failure"
|
# echo "This is a force failure"
|
||||||
exit 1
|
# exit 1
|
||||||
|
|
||||||
- name: Second Chat Message as ThreadResponse
|
- name: Second Chat Message as ThreadResponse
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
|
|
|
||||||
49
.github/workflows/release.yml
vendored
49
.github/workflows/release.yml
vendored
|
|
@ -7,6 +7,9 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
VER: 0.3.1
|
||||||
|
|
||||||
# If a 403 error occurs, make sure to set content permission to write
|
# If a 403 error occurs, make sure to set content permission to write
|
||||||
# see: https://github.com/go-semantic-release/action/issues/27
|
# see: https://github.com/go-semantic-release/action/issues/27
|
||||||
permissions:
|
permissions:
|
||||||
|
|
@ -22,10 +25,14 @@ jobs:
|
||||||
- name: Setup GO
|
- name: Setup GO
|
||||||
uses: actions/setup-go@v6
|
uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version: 1.26
|
# go-version: 1.26
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
cache-dependency-path: 'go.sum'
|
||||||
|
|
||||||
- name: GO Linting
|
- name: GO Linting
|
||||||
uses: golangci/golangci-lint-action@v3
|
uses: golangci/golangci-lint-action@v9
|
||||||
|
with:
|
||||||
|
version: v2.11
|
||||||
|
|
||||||
# build:
|
# build:
|
||||||
# runs-on: stackit-docker
|
# runs-on: stackit-docker
|
||||||
|
|
@ -47,6 +54,18 @@ jobs:
|
||||||
outputs:
|
outputs:
|
||||||
tag: ${{ steps.create_release.outputs.tag }}
|
tag: ${{ steps.create_release.outputs.tag }}
|
||||||
steps:
|
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
|
- name: Checkout code
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
|
@ -72,6 +91,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
npx \
|
npx \
|
||||||
-p semantic-release \
|
-p semantic-release \
|
||||||
|
-p semantic-release-replace-plugin \
|
||||||
-p @semantic-release/commit-analyzer \
|
-p @semantic-release/commit-analyzer \
|
||||||
-p @semantic-release/release-notes-generator \
|
-p @semantic-release/release-notes-generator \
|
||||||
-p @semantic-release/changelog \
|
-p @semantic-release/changelog \
|
||||||
|
|
@ -95,8 +115,29 @@ jobs:
|
||||||
if: steps.create_release.outputs.tag != ''
|
if: steps.create_release.outputs.tag != ''
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build only
|
||||||
|
if: steps.create_release.outputs.tag == ''
|
||||||
uses: docker/build-push-action@v7
|
uses: docker/build-push-action@v7
|
||||||
with:
|
with:
|
||||||
push: false
|
push: false
|
||||||
tags: actions/notify-slim:${{ steps.create_release.outputs.tag }}
|
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'
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,7 @@ linters:
|
||||||
- name: empty-lines
|
- name: empty-lines
|
||||||
- name: early-return
|
- name: early-return
|
||||||
exclusions:
|
exclusions:
|
||||||
paths:
|
paths: []
|
||||||
- generator/
|
|
||||||
- internal/testutils
|
|
||||||
generated: lax
|
generated: lax
|
||||||
warn-unused: true
|
warn-unused: true
|
||||||
# Excluding configuration per-path, per-linter, per-text and per-source.
|
# Excluding configuration per-path, per-linter, per-text and per-source.
|
||||||
|
|
@ -3,8 +3,76 @@
|
||||||
"tagFormat": "v${version}",
|
"tagFormat": "v${version}",
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"@semantic-release/commit-analyzer",
|
"@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/release-notes-generator",
|
||||||
"@semantic-release/changelog",
|
"@semantic-release/changelog",
|
||||||
"@semantic-release/git"
|
[
|
||||||
|
"@semantic-release/git",
|
||||||
|
{
|
||||||
|
"assets": ["CHANGELOG.md", "README.md", "action.yml", ".github/workflows/example.yml", ".github/workflows/release.yml"]
|
||||||
|
}
|
||||||
|
]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
15
CHANGELOG.md
15
CHANGELOG.md
|
|
@ -1,3 +1,18 @@
|
||||||
|
## [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)
|
# [0.2.0](https://stackit-solutions.git.onstackit.cloud/actions/notify/compare/v0.1.2...v0.2.0) (2026-04-17)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ jobs:
|
||||||
# ... all your steps
|
# ... all your steps
|
||||||
- name: Sample Chat Message
|
- name: Sample Chat Message
|
||||||
if: ${{ always() }} # runs als after fails
|
if: ${{ always() }} # runs als after fails
|
||||||
uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v0.1.2
|
uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v0.3.1
|
||||||
with:
|
with:
|
||||||
title: "[START] sample test (${{ forgejo.run_number }})"
|
title: "[START] sample test (${{ forgejo.run_number }})"
|
||||||
author: ${{ forgejo.actor }}
|
author: ${{ forgejo.actor }}
|
||||||
|
|
|
||||||
6
go.sum
Normal file
6
go.sum
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
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=
|
||||||
100
main.go
100
main.go
|
|
@ -42,6 +42,56 @@ func main() {
|
||||||
data.CardID = uuid.NewString()
|
data.CardID = uuid.NewString()
|
||||||
data.Add = ""
|
data.Add = ""
|
||||||
|
|
||||||
|
getData(&data)
|
||||||
|
|
||||||
|
webhook := githubactions.GetInput("webhook")
|
||||||
|
if webhook == "" {
|
||||||
|
githubactions.Fatalf("Missing input 'webhook'")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
webhook = fmt.Sprintf("%s&threadKey=notify%s&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD", webhook, data.ActionID)
|
||||||
|
|
||||||
|
giturl := githubactions.GetInput("giturl")
|
||||||
|
if giturl == "" {
|
||||||
|
githubactions.Fatalf("Missing input 'giturl'")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
data.GitURL = giturl
|
||||||
|
|
||||||
|
body := githubactions.GetInput("event_body")
|
||||||
|
data.EventBody = body
|
||||||
|
|
||||||
|
githubactions.Infof("using URL: %s", webhook)
|
||||||
|
|
||||||
|
jsonStr, err := card(data)
|
||||||
|
if err != nil {
|
||||||
|
githubactions.Fatalf("err %s", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr))
|
||||||
|
if err != nil {
|
||||||
|
githubactions.Fatalf("error %s", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
req.Header.Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
|
client := &http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
githubactions.Fatalf("error %s", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close() //nolint:gocritic
|
||||||
|
|
||||||
|
fmt.Println("response Status:", resp.Status)
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
githubactions.Infof("json: %s", jsonStr)
|
||||||
|
githubactions.Fatalf("response: %+v\n", resp)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getData(data *templateData) {
|
||||||
prj, ok := os.LookupEnv("FORGEJO_REPOSITORY")
|
prj, ok := os.LookupEnv("FORGEJO_REPOSITORY")
|
||||||
if ok {
|
if ok {
|
||||||
data.Project = prj
|
data.Project = prj
|
||||||
|
|
@ -84,56 +134,6 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
data.ActionID = actionid
|
data.ActionID = actionid
|
||||||
|
|
||||||
webhook := githubactions.GetInput("webhook")
|
|
||||||
if webhook == "" {
|
|
||||||
githubactions.Fatalf("Missing input 'webhook'")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
webhook = fmt.Sprintf("%s&threadKey=notify%s&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD", webhook, data.ActionID)
|
|
||||||
|
|
||||||
giturl := githubactions.GetInput("giturl")
|
|
||||||
if giturl == "" {
|
|
||||||
githubactions.Fatalf("Missing input 'giturl'")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
data.GitURL = giturl
|
|
||||||
|
|
||||||
body := githubactions.GetInput("event_body")
|
|
||||||
data.EventBody = body
|
|
||||||
|
|
||||||
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)
|
|
||||||
if err != nil {
|
|
||||||
githubactions.Fatalf("error %s", err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// log.Printf("retrieved data: %s", string(jsonStr))
|
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr))
|
|
||||||
if err != nil {
|
|
||||||
githubactions.Fatalf("error %s", err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
req.Header.Set("Content-Type", "application/json; charset=UTF-8")
|
|
||||||
client := &http.Client{}
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
githubactions.Fatalf("error %s", err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
fmt.Println("response Status:", resp.Status)
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
githubactions.Infof("json: %s", jsonStr)
|
|
||||||
githubactions.Fatalf("response: %+v\n", resp)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func card(d templateData) ([]byte, error) {
|
func card(d templateData) ([]byte, error) {
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,6 @@ 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",
|
||||||
|
|
@ -115,9 +113,6 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue