test
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Details
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Details
This commit is contained in:
parent
476ba36732
commit
ca29252001
|
@ -0,0 +1,18 @@
|
||||||
|
name: Gitea Actions Demo
|
||||||
|
run-name: ${{ github.actor }} is testing out Gitea Actions
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
Explore-Gitea-Actions:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo " The job was automatically triggered by a ${{ github.event_name }} event."
|
||||||
|
- run: echo " This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||||
|
- run: echo " The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- run: echo " The ${{ github.repository }} repository has been cloned to the runner."
|
||||||
|
- run: echo " ️ The workflow is now ready to test your code on the runner."
|
||||||
|
- name: List files in the repository
|
||||||
|
run: |
|
||||||
|
ls ${{ github.workspace }}
|
||||||
|
- run: echo " This job's status is ${{ job.status }}."
|
31
action.yml
31
action.yml
|
@ -1,19 +1,12 @@
|
||||||
name: 'Test Go Action'
|
name: 'Simple Go Action'
|
||||||
on: [push]
|
description: 'A simple Gitea action written in go'
|
||||||
jobs:
|
inputs:
|
||||||
use-go-action:
|
username:
|
||||||
runs-on: ubuntu-latest
|
description: 'The username to print'
|
||||||
steps:
|
required: true
|
||||||
- name: Setup Go
|
outputs:
|
||||||
uses: actions/setup-go@v3
|
time:
|
||||||
with:
|
description: 'The time when the action was called'
|
||||||
go-version: '1.20'
|
runs:
|
||||||
|
using: 'go'
|
||||||
- name: Use Go Action
|
main: 'main.go'
|
||||||
id: use-go-action
|
|
||||||
uses: <action-url>
|
|
||||||
with:
|
|
||||||
username: foo
|
|
||||||
|
|
||||||
- name: Print Output
|
|
||||||
run: echo 'output time is ${{ steps.use-go-action.outputs.time }}'
|
|
34
main.go
34
main.go
|
@ -2,15 +2,39 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
gha "github.com/sethvargo/go-githubactions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
username := readInputs()
|
||||||
username := gha.GetInput("username")
|
|
||||||
fmt.Printf("username is %s\n", username)
|
fmt.Printf("username is %s\n", username)
|
||||||
|
|
||||||
gha.SetOutput("time", time.Now().Format("2006-01-02 15:04:05"))
|
err := writeOutputs("time", time.Now().Format("2006-01-02 15:04:05"))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func readInputs() string {
|
||||||
|
username := os.Getenv("INPUT_USERNAME")
|
||||||
|
return username
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeOutputs(k, v string) (err error) {
|
||||||
|
msg := fmt.Sprintf("%s=%s", k, v)
|
||||||
|
outputFilepath := os.Getenv("GITHUB_OUTPUT")
|
||||||
|
f, err := os.OpenFile(outputFilepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if cErr := f.Close(); cErr != nil && err == nil {
|
||||||
|
err = cErr
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if _, err = f.Write([]byte(msg)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
Loading…
Reference in New Issue