Skip to content

Commit

Permalink
general set trigger event
Browse files Browse the repository at this point in the history
  • Loading branch information
root27 committed Mar 29, 2024
1 parent 928b93a commit b1cbcdc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: deploy
name: test
"on":
push:
branches:
Expand Down
44 changes: 11 additions & 33 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ type Workflow struct {
Jobs Jobs `yaml:"jobs"`
}

// type On struct {
// Push Push `yaml:"push"`
// Pull Pull `yaml:"pull_request"`
// }

type Pull struct {
Branches []string `yaml:"branches"`
}

type Push struct {
Branches []string `yaml:"branches"`
}

type Jobs struct {
Deploy Deploy `yaml:"deploy"`
}
Expand All @@ -36,15 +23,15 @@ type Deploy struct {
}

type Step struct {
Uses string `yaml:"uses,omitempty"`
Name string `yaml:"name,omitempty"`
Env Env `yaml:"env,omitempty"`
Run string `yaml:"run,omitempty"`
Uses string `yaml:"uses,omitempty"`
Name string `yaml:"name,omitempty"`
Env interface{} `yaml:"env"`
Run string `yaml:"run,omitempty"`
}

type Env struct {
ServerKey string `yaml:"SERVER_KEY,omitempty"`
}
// type Env struct {
// ServerKey string `yaml:"SERVER_KEY,omitempty"`
// }

func main() {

Expand All @@ -67,19 +54,10 @@ func main() {

workflow.Name = workFlowName

if triggerEvent == "push" {
workflow.On = map[string]interface{}{
"push": map[string]interface{}{
"branches": []string{onBranch},
},
}
} else {
workflow.On = map[string]interface{}{
"pull_request": map[string]interface{}{
"branches": []string{onBranch},
},
}

workflow.On = map[string]interface{}{
triggerEvent: map[string]interface{}{
"branches": []string{onBranch},
},
}

workflow.Jobs.Deploy.RunsOn = "ubuntu-latest"
Expand Down

0 comments on commit b1cbcdc

Please sign in to comment.