Skip to content

Commit

Permalink
feat: add github workflows into workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
lgdd committed Apr 26, 2024
1 parent 0489cd4 commit ae2d650
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lfr/pkg/assets/tpl/gh/liferay-upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# https://github.com/marketplace/actions/liferay-upgrade
name: Liferay Upgrade

on:
schedule:
- cron: '0 0 * * MON,THU'

# Settings > Actions > General > Read and write permissions
# Settings > Actions > General > Allow GitHub Actions to create and approve pull requests
permissions:
contents: write
pull-requests: write

jobs:
liferay-upgrade:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: lgdd/liferay-upgrade-action@v2
with:
java-distribution: 'zulu'
java-version: '{{ .JavaVersion }}'

# Checkout more GitHub Actions for Liferay:
# https://github.com/marketplace?type=actions&query=liferay
27 changes: 27 additions & 0 deletions lfr/pkg/generate/workspace/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/lgdd/lfr-cli/lfr/pkg/project"
"github.com/lgdd/lfr-cli/lfr/pkg/util/fileutil"
"github.com/lgdd/lfr-cli/lfr/pkg/util/printutil"
"github.com/lgdd/lfr-cli/lfr/pkg/util/procutil"
)

// Build options (i.e. Maven or Gradle)
Expand Down Expand Up @@ -48,6 +49,8 @@ func Generate(base, build, version, edition string) error {
return errors.New("only Gradle and Maven are supported")
}

createGithubWorkflows(base)

_ = filepath.Walk(base,
func(path string, info os.FileInfo, err error) error {
if err != nil {
Expand Down Expand Up @@ -209,3 +212,27 @@ func createCommonEmptyDirs(base string) {
fileutil.CreateFiles([]string{filepath.Join(configCommonDir, ".gitkeep")})
fileutil.CreateFiles([]string{filepath.Join(configDockerDir, ".gitkeep")})
}

func createGithubWorkflows(base string) error {
javaVersion := "11"
githubWorkflowsDir := filepath.Join(base, ".github", "workflows")
fileutil.CreateDirs(filepath.Join(base, ".github", "workflows"))

err := fileutil.CreateFilesFromAssets("tpl/gh", githubWorkflowsDir)

if err != nil {
return err
}

major, _, err := procutil.GetCurrentJavaVersion()

if err == nil && (major == "8" || major == "11") {
javaVersion = major
}

err = fileutil.UpdateWithData(filepath.Join(githubWorkflowsDir, "liferay-upgrade.yml"), struct {
JavaVersion string
}{JavaVersion: javaVersion})

return err
}

0 comments on commit ae2d650

Please sign in to comment.