This commit is contained in:
21
.github/workflows/update.yml
vendored
Normal file
21
.github/workflows/update.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: '代码更新通知'
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
update-server:
|
||||
runs-on: home-lab
|
||||
steps:
|
||||
- name: 输出当前目录环境
|
||||
run: pwd && ls -ahl
|
||||
- name: 发送通知
|
||||
id: use-go-action
|
||||
uses: https://git.aweoo.com/learning/simple-go-action@latest
|
||||
with:
|
||||
username: foo
|
||||
- name: Print Output
|
||||
run: echo 'output time is ${{ steps.use-go-action.outputs.time }}'
|
||||
- name: 错误处理
|
||||
if: ${{ failure() }}
|
||||
run: |
|
||||
echo '出错了 你个笨蛋'
|
||||
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.idea/
|
||||
_tmp/
|
||||
out/
|
||||
dist/
|
||||
14
action.yaml
Normal file
14
action.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
name: 'Simple Go Action'
|
||||
description: 'A simple Gitea Action written in Go'
|
||||
inputs:
|
||||
username:
|
||||
description: 'The username to print'
|
||||
required: true
|
||||
outputs:
|
||||
time:
|
||||
description: 'The time when the action was called'
|
||||
runs:
|
||||
using: 'go'
|
||||
main: 'main.go'
|
||||
pre: 'pre/main.go'
|
||||
post: 'post/main.go'
|
||||
5
go.mod
Normal file
5
go.mod
Normal file
@@ -0,0 +1,5 @@
|
||||
module git.aweoo.com/action/gotify
|
||||
|
||||
go 1.23.3
|
||||
|
||||
require github.com/sethvargo/go-githubactions v1.3.0 // indirect
|
||||
2
go.sum
Normal file
2
go.sum
Normal file
@@ -0,0 +1,2 @@
|
||||
github.com/sethvargo/go-githubactions v1.3.0 h1:Kg633LIUV2IrJsqy2MfveiED/Ouo+H2P0itWS0eLh8A=
|
||||
github.com/sethvargo/go-githubactions v1.3.0/go.mod h1:7/4WeHgYfSz9U5vwuToCK9KPnELVHAhGtRwLREOQV80=
|
||||
27
main.go
Normal file
27
main.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/sethvargo/go-githubactions"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
ctx, err := githubactions.Context()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
body, err := json.Marshal(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("context: %s\n", string(body))
|
||||
|
||||
username := githubactions.GetInput("username")
|
||||
fmt.Printf("username is %s\n", username)
|
||||
|
||||
githubactions.SetOutput("time", time.Now().Format("2006-01-02 15:04:05"))
|
||||
}
|
||||
7
post/main.go
Normal file
7
post/main.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("Post of Simple Go Action")
|
||||
}
|
||||
7
pre/main.go
Normal file
7
pre/main.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("Pre of Simple Go Action")
|
||||
}
|
||||
Reference in New Issue
Block a user