diff --git a/.github/workflows/docs-commands-generate.yml b/.github/workflows/docs-commands-generate.yml new file mode 100644 index 0000000..139067f --- /dev/null +++ b/.github/workflows/docs-commands-generate.yml @@ -0,0 +1,45 @@ +name: Generate commands documentation + +on: + push: + branches: + - develop + - hotfix/* + +permissions: + contents: write + +jobs: + docs-commands-generate: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.21 + + - name: Run GoReleaser artifact build + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: v1.23.0 + args: build --clean --skip=validate + + - name: Generate and commit new commands documentation + run: | + echo "Configure Git user.name and user.email." + git config user.name github-actions + git config user.email github-actions@github.com + + echo "Generate new commands documentation." + ./dist/rmk_linux_amd64_v1/rmk doc generate > ./docs/commands.md + + if (git commit --all --message="Update commands documentation"); then + git push + echo "The new commands documentation has been committed." + fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d8d71a8..9ca7749 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,14 +45,14 @@ jobs: GIT_COMMIT_MSG="$(git log -1 --pretty=format:"%s")" echo "${GIT_COMMIT_MSG}" - if [[ ! "${GIT_COMMIT_MSG}" =~ ^Merge\ pull\ request\ #[0-9]+\ from\ ${GITHUB_ORG}/release/(v[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then - >&2 echo "Pushes to master should be done via merges of PR requests from release/vN.N.N branches only." + if [[ ! "${GIT_COMMIT_MSG}" =~ ^Merge\ pull\ request\ #[0-9]+\ from\ ${GITHUB_ORG}/(hotfix|release)/(v[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then + >&2 echo "Pushes to master should be done via merges of PR requests from hotfix/vN.N.N or release/vN.N.N branches only." >&2 echo "The expected message format (will be used for parsing a release tag):" - >&2 echo "Merge pull request #N from edenlabllc/release/vN.N.N" + >&2 echo "Merge pull request #N from ${GITHUB_ORG}/hotfix/vN.N.N or ${GITHUB_ORG}/release/vN.N.N." exit 1 fi - VERSION="${BASH_REMATCH[1]}" + VERSION="${BASH_REMATCH[2]}" echo "DISABLE_BLOB_RMK_RC=true" >> "${GITHUB_ENV}" } diff --git a/commands/container_registry_category.go b/commands/container_registry_category.go index a73a260..7e93127 100644 --- a/commands/container_registry_category.go +++ b/commands/container_registry_category.go @@ -42,7 +42,7 @@ func (cr *CRCommands) dockerLogin() error { } if token, ok := credentials[cr.Conf.AWSECRUserName]; !ok { - return fmt.Errorf("failed to get token") + return fmt.Errorf("failed to get ECR token") } else { if cr.Ctx.Bool("get-token") { fmt.Println(token) diff --git a/commands/flags.go b/commands/flags.go index d828be0..e875706 100644 --- a/commands/flags.go +++ b/commands/flags.go @@ -190,11 +190,11 @@ func flagsConfigList() []cli.Flag { func flagsClusterK3DCreate() []cli.Flag { return append(flagsHidden(), &cli.StringFlag{ - Name: "k3d-volume-host-path", - Usage: "host local directory path for mount into K3D cluster", - Aliases: []string{"kv"}, - EnvVars: []string{"RMK_K3D_VOLUME_HOST_PATH"}, - Value: system.GetPwdPath(""), + Name: "k3d-volume-host-path", + Usage: "host local directory path for mount into K3D cluster", + Aliases: []string{"kv"}, + EnvVars: []string{"RMK_K3D_VOLUME_HOST_PATH"}, + DefaultText: "present working directory", }, ) } diff --git a/commands/k3d_category.go b/commands/k3d_category.go index 6e74beb..10a67ee 100644 --- a/commands/k3d_category.go +++ b/commands/k3d_category.go @@ -46,15 +46,21 @@ func (k *K3DCommands) prepareK3D(args ...string) error { return err } - for key, val := range credentials { - k.SpecCMD.Envs = append(k.SpecCMD.Envs, - "K3D_NAME="+k.Conf.Name, - "K3D_VOLUME_HOST_PATH="+k.Ctx.String("k3d-volume-host-path"), - "K3D_AWS_ECR_USER="+key, - "K3D_AWS_ECR_PASSWORD="+val, - ) + k.SpecCMD.Envs = append(k.SpecCMD.Envs, "K3D_NAME="+k.Conf.Name) + + if token, ok := credentials[k.Conf.AWSECRUserName]; !ok { + return fmt.Errorf("failed to get ECR token") + } else { + k.SpecCMD.Envs = append(k.SpecCMD.Envs, "K3D_AWS_ECR_USER="+k.Conf.AWSECRUserName, "K3D_AWS_ECR_PASSWORD="+token) + } + + if len(k.Ctx.String("k3d-volume-host-path")) > 0 { + k.SpecCMD.Envs = append(k.SpecCMD.Envs, "K3D_VOLUME_HOST_PATH="+k.Ctx.String("k3d-volume-host-path")) + return nil } + k.SpecCMD.Envs = append(k.SpecCMD.Envs, "K3D_VOLUME_HOST_PATH="+system.GetPwdPath("")) + return nil } diff --git a/docs/release-notes.md b/docs/release-notes.md index 8a638b7..00dead0 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,3 +1 @@ -- #18 - Fixed links to the OSS repository in project generation. -- #18 - Split the issue template into the bug and feature templates. -- #18 - Updated the Roadmap section of README.md. +- #33 - Added a new GitHub action for RMK commands documentation generation.