Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
root27 committed Mar 29, 2024
1 parent b1cbcdc commit 659cc8a
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"strings"

"gopkg.in/yaml.v2"
)
Expand All @@ -18,8 +19,8 @@ type Jobs struct {
}

type Deploy struct {
RunsOn string `yaml:"runs-on"`
Steps []Step `yaml:"steps"`
RunsOn string `yaml:"runs-on"`
Steps interface{} `yaml:"steps"`
}

type Step struct {
Expand Down Expand Up @@ -48,6 +49,17 @@ func main() {
var onBranch string
fmt.Scanln(&onBranch)

fmt.Print("Would you like to add a secret? (y/n): ")
var addSecret string
fmt.Scanln(&addSecret)

if strings.ToLower(addSecret) == "y" {
fmt.Print("Enter the secret name: ")
var secretName string
fmt.Scanln(&secretName)

}

// Populate the Workflow struct

workflow := Workflow{}
Expand All @@ -61,16 +73,24 @@ func main() {
}

workflow.Jobs.Deploy.RunsOn = "ubuntu-latest"
workflow.Jobs.Deploy.Steps = []Step{
{
Uses: "actions/checkout@v2",
},
{
Name: "Deploy to server",
Env: Env{
ServerKey: "${{ secrets.SERVER_KEY }}",
},
Run: `echo "$SERVER_KEY" > secret && chmod 600 secret && ssh -o StrictHostKeyChecking=no -i secret [email protected] -p 8357 'ls -la'`,
// workflow.Jobs.Deploy.Steps = []Step{
// {
// Uses: "actions/checkout@v2",
// },
// {
// Name: "Deploy to server",
// Env: map[string]interface{}{
// secretName: "${{ secrets." + secretName + " }}",
// },
// Run: `echo "$SERVER_KEY" > secret && chmod 600 secret && ssh -o StrictHostKeyChecking=no -i secret [email protected] -p 8357 'ls -la'`,
// },
// }

workflow.Jobs.Deploy.Steps = map[string]interface{}{
"uses": "actions/checkout@v2",
"name": "Deploy to server",
"env": map[string]interface{}{
secretName: "${{ secrets." + secretName + " }}",
},
}

Expand Down

0 comments on commit 659cc8a

Please sign in to comment.