Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update scaffold to create Github action PR #38

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions internal/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func (s *Scaffold) generate(fs afero.Fs, rootpath string, adminteam string) erro
return fmt.Errorf("Error creating the goliac.yaml file: %v", err)
}

if err := s.generateGithubAction(fs, rootpath); err != nil {
return fmt.Errorf("Error creating the .github/workflows/pr.yaml file: %v", err)
}

return nil
}

Expand Down Expand Up @@ -314,6 +318,32 @@ usersync:
return nil
}

func (s *Scaffold) generateGithubAction(fs afero.Fs, rootpath string) error {
workflow := `
name: Validate structure

on: [pull_request]

jobs:
build:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Verify
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/nzin/goliac
options: -v ${{ github.workspace }}:/work
run: /app/goliac verify /work
`
if err := writeFile(path.Join(rootpath, ".github", "workflows", "pr.yaml"), []byte(workflow), fs); err != nil {
return err
}
return nil
}

func writeFile(filename string, content []byte, fs afero.Fs) error {
file, err := fs.Create(filename)
if err == nil {
Expand Down