diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f0edd0f1..a02467e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -132,6 +132,7 @@ jobs: - name: Test action uses: ./ + if: github.event_name == 'push' - name: Run build run: make build diff --git a/README.md b/README.md index 1eeafa19..aacdb6dc 100644 --- a/README.md +++ b/README.md @@ -64,21 +64,25 @@ and/or `Description` (only supported by actions) -| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION | -|-------------------------|--------|----------|----------------|--------------------------------------------------------------------------------------------------| -| bin\_path | string | false | | Path to the auto-doc binary | -| col\_max\_width | string | false | `"1000"` | Max width of a column | -| col\_max\_words | string | false | `"5"` | Max number of words per line
in a column | -| filename | string | false | `"action.yml"` | Path to the yaml file | -| input\_columns | string | false | | List of action.yml **input** columns names
to display, default (display all columns) | -| markdown\_links | string | false | `"true"` | Boolean indicating whether to output input,
output and secret names as markdown
links | -| output | string | false | `"README.md"` | Path to the output file | -| output\_columns | string | false | | List of action.yml **output** column names
to display, default (display all columns) | -| reusable | string | false | | Boolean Indicating whether the file is
a reusable workflow | -| reusable\_input\_columns | string | false | | List of reusable workflow **input** column
names to display, default (display all columns) | -| reusable\_output\_columns | string | false | | List of reusable workflow **output** column
names to display, default (display all columns) | -| reusable\_secret\_columns | string | false | | List of reusable workflow **secret** column
names to display, default (display all columns) | -| version | string | false | | The version number to run | +| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION | +|-------------------------|--------|----------|------------------------------|--------------------------------------------------------------------------------------------------| +| bin\_path | string | false | | Path to the auto-doc binary | +| col\_max\_width | string | false | `"1000"` | Max width of a column | +| col\_max\_words | string | false | `"5"` | Max number of words per line
in a column | +| filename | string | false | `"action.yml"` | Path to the yaml file | +| input\_columns | string | false | | List of action.yml **input** columns names
to display, default (display all columns) | +| markdown\_links | string | false | `"true"` | Boolean indicating whether to output input,
output and secret names as markdown
links | +| output | string | false | `"README.md"` | Path to the output file | +| output\_columns | string | false | | List of action.yml **output** column names
to display, default (display all columns) | +| repository | string | false | `"${{ github.repository }}"` | Repository name with owner. For example,
tj-actions/auto-doc | +| reusable | string | false | | Boolean Indicating whether the file is
a reusable workflow | +| reusable\_input\_columns | string | false | | List of reusable workflow **input** column
names to display, default (display all columns) | +| reusable\_output\_columns | string | false | | List of reusable workflow **output** column
names to display, default (display all columns) | +| reusable\_secret\_columns | string | false | | List of reusable workflow **secret** column
names to display, default (display all columns) | +| token | string | false | `"${{ github.token }}"` | GitHub token or Personal Access Token
used to fetch the repository latest
tag. | +| use\_code\_blocks | string | false | `"false"` | Enable code block documentation | +| use\_major\_version | string | false | `"false"` | Use the major version of the
repository tag e.g v1.0.0 -> v1 | +| version | string | false | | The version number to run | @@ -156,18 +160,22 @@ Automatically generate documentation for your custom github action or reusable w ### Flags - --colMaxWidth string Max width of a column (default "1000") - --colMaxWords string Max number of words per line in a column (default "6") - -f, --filename string config file + --colMaxWidth string Max width of a column. (default "1000") + --colMaxWords string Max number of words per line in a column. (default "6") + -f, --filename string config file. -h, --help help for auto-doc - --inputColumns stringArray list of input column names (default [Input,Type,Required,Default,Description]) - -m, --markdownLinks Names of inputs, outputs and secrets as markdown links - -o, --output string Output file (default "README.md") - --outputColumns stringArray list of output column names (default [Output,Type,Description]) - -r, --reusable A reusable workflow - --reusableInputColumns stringArray list of reusable input column names (default [Input,Type,Required,Default,Description]) - --reusableOutputColumns stringArray list of reusable output column names (default [Output,Value,Description]) - --reusableSecretColumns stringArray list of reusable secrets column names (default [Secret,Required,Description]) + --inputColumns stringArray list of input column names. (default [Input,Type,Required,Default,Description]) + -m, --markdownLinks Names of inputs, outputs and secrets as markdown links. + -o, --output string Output file. (default "README.md") + --outputColumns stringArray list of output column names. (default [Output,Type,Description]) + --repository string Repository name with owner. Example: tj-actions/auto-doc + -r, --reusable A reusable workflow. + --reusableInputColumns stringArray list of reusable input column names. (default [Input,Type,Required,Default,Description]) + --reusableOutputColumns stringArray list of reusable output column names. (default [Output,Value,Description]) + --reusableSecretColumns stringArray list of reusable secrets column names. (default [Secret,Required,Description]) + --token string GitHub token or Personal Access Token used to fetch the repository latest tag. + --useCodeBlocks Enable code block documentation. + --useMajorVersion Use the major version of the repository tag. Example: v1.0.0 -> v Use the major version of the repository tag. e.g v1.0.0 -> v1 * Free software: [Apache License 2.0](LICENSE) diff --git a/action.yml b/action.yml index c443f729..22c9c6e9 100644 --- a/action.yml +++ b/action.yml @@ -46,6 +46,23 @@ inputs: description: 'Boolean indicating whether to output input, output and secret names as markdown links' required: false default: 'true' + repository: + description: 'Repository name with owner. For example, tj-actions/auto-doc' + required: false + default: ${{ github.repository }} + token: + description: 'GitHub token or Personal Access Token used to fetch the repository latest tag.' + required: false + default: ${{ github.token }} + use_code_blocks: + description: 'Enable code block documentation' + required: false + default: 'false' + use_major_version: + description: 'Use the major version of the repository tag e.g v1.0.0 -> v1' + required: false + default: 'false' + runs: using: 'composite' @@ -79,6 +96,10 @@ runs: INPUT_REUSABLE: ${{ inputs.reusable }} INPUT_VERSION: ${{ inputs.version }} INPUT_MARKDOWN_LINKS: ${{ inputs.markdown_links }} + INPUT_REPOSITORY: ${{ inputs.repository }} + INPUT_TOKEN: ${{ inputs.token }} + INPUT_USE_CODE_BLOCKS: ${{ inputs.use_code_blocks }} + INPUT_USE_MAJOR_VERSION: ${{ inputs.use_major_version }} branding: icon: file-text diff --git a/cmd/root.go b/cmd/root.go index 57e228c5..20c1fd0c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -29,6 +29,8 @@ var fileName string var outputFileName string var colMaxWidth string var colMaxWords string +var repository string +var token string // action.yml var inputColumns []string @@ -70,6 +72,22 @@ func RootCmdRunE(cmd *cobra.Command, args []string) error { return err } + useCodeBlocks, err := cmd.Flags().GetBool("useCodeBlocks") + // coverage:ignore + if err != nil { + return err + } + + useMajorVersion, err := cmd.Flags().GetBool("useMajorVersion") + // coverage:ignore + if err != nil { + return err + } + + if repository == "" && useCodeBlocks { + return fmt.Errorf("repository must be specified with --repository") + } + var documentation types.Documentation if reusable { @@ -83,6 +101,18 @@ func RootCmdRunE(cmd *cobra.Command, args []string) error { SecretColumns: reusableSecretColumns, InputMarkdownLinks: markdownLinks, } + } else if useCodeBlocks { + documentation = &types.CodeBlock{ + Repository: repository, + Token: token, + UseMajorVersion: useMajorVersion, + InputFileName: fileName, + OutputFileName: outputFileName, + OutputColumns: outputColumns, + ColMaxWidth: colMaxWidth, + ColMaxWords: colMaxWords, + InputMarkdownLinks: markdownLinks, + } } else { documentation = &types.Action{ InputFileName: fileName, @@ -129,68 +159,90 @@ func RootCmdFlags(cmd *cobra.Command) { "filename", "f", "", - "config file", + "config file.", ) cmd.Flags().BoolP( "reusable", "r", false, - "A reusable workflow", + "A reusable workflow.", ) cmd.Flags().StringVarP( &outputFileName, "output", "o", "README.md", - "Output file", + "Output file.", ) cmd.Flags().StringVar( &colMaxWidth, "colMaxWidth", "1000", - "Max width of a column", + "Max width of a column.", ) cmd.Flags().StringVar( &colMaxWords, "colMaxWords", "6", - "Max number of words per line in a column", + "Max number of words per line in a column.", ) cmd.Flags().StringArrayVar( &inputColumns, "inputColumns", internal.DefaultActionInputColumns, - "list of input column names", + "list of input column names.", ) cmd.Flags().StringArrayVar( &outputColumns, "outputColumns", internal.DefaultActionOutputColumns, - "list of output column names", + "list of output column names.", ) cmd.Flags().StringArrayVar( &reusableInputColumns, "reusableInputColumns", internal.DefaultReusableInputColumns, - "list of reusable input column names", + "list of reusable input column names.", ) cmd.Flags().StringArrayVar( &reusableOutputColumns, "reusableOutputColumns", internal.DefaultReusableOutputColumns, - "list of reusable output column names", + "list of reusable output column names.", ) cmd.Flags().StringArrayVar( &reusableSecretColumns, "reusableSecretColumns", internal.DefaultReusableSecretColumns, - "list of reusable secrets column names", + "list of reusable secrets column names.", ) cmd.Flags().BoolP( "markdownLinks", "m", false, - "Names of inputs, outputs and secrets as markdown links", + "Names of inputs, outputs and secrets as markdown links.", + ) + cmd.Flags().StringVar( + &repository, + "repository", + "", + "Repository name with owner. Example: tj-actions/auto-doc", + ) + cmd.Flags().StringVar( + &token, + "token", + "", + "GitHub token or Personal Access Token used to fetch the repository latest tag.", + ) + cmd.Flags().Bool( + "useCodeBlocks", + false, + "Enable code block documentation.", + ) + cmd.Flags().Bool( + "useMajorVersion", + false, + "Use the major version of the repository tag. Example: v1.0.0 -> v1", ) } diff --git a/cmd/root_test.go b/cmd/root_test.go index 23429865..750b6bca 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -259,7 +259,7 @@ func Test_rootCommand(t *testing.T) { } }) - t.Run("Update test/README-reusable.md using custom action file and output file", func(t *testing.T) { + t.Run("Update test/README-reusable.md using custom reusable workflow file and output file", func(t *testing.T) { cmd := &cobra.Command{Use: "auto-doc", RunE: RootCmdRunE} RootCmdFlags(cmd) b := bytes.NewBufferString("") @@ -515,4 +515,62 @@ func Test_rootCommand(t *testing.T) { ) } }) + + t.Run("Update test/README-codeBlocks.md using custom action file and output file", func(t *testing.T) { + cmd := &cobra.Command{Use: "auto-doc", RunE: RootCmdRunE} + RootCmdFlags(cmd) + b := bytes.NewBufferString("") + cmd.SetOut(b) + inputFile := filepath.Join("..", "test", "action.yml") + mdFile := filepath.Join("..", "test", "README-codeBlocks.md") + cmd.SetArgs([]string{"--filename", inputFile, "--output", mdFile, "--repository", "tj-actions/changed-files", "--useCodeBlocks"}) + err := cmd.Execute() + if err != nil { + t.Fatal(err) + } + + out, err := io.ReadAll(b) + if err != nil { + t.Fatal(err) + } + + exp := fmt.Sprintln("Successfully generated documentation") + + if string(out) != exp { + t.Fatalf( + "expected \"%s\" got \"%s\"", + exp, + string(out), + ) + } + }) + + t.Run("Update test/README-codeBlocksMajorVersion.md using custom action file and output file", func(t *testing.T) { + cmd := &cobra.Command{Use: "auto-doc", RunE: RootCmdRunE} + RootCmdFlags(cmd) + b := bytes.NewBufferString("") + cmd.SetOut(b) + inputFile := filepath.Join("..", "test", "action.yml") + mdFile := filepath.Join("..", "test", "README-codeBlocksMajorVersion.md") + cmd.SetArgs([]string{"--filename", inputFile, "--output", mdFile, "--repository", "tj-actions/changed-files", "--useCodeBlocks", "--useMajorVersion"}) + err := cmd.Execute() + if err != nil { + t.Fatal(err) + } + + out, err := io.ReadAll(b) + if err != nil { + t.Fatal(err) + } + + exp := fmt.Sprintln("Successfully generated documentation") + + if string(out) != exp { + t.Fatalf( + "expected \"%s\" got \"%s\"", + exp, + string(out), + ) + } + }) } diff --git a/entrypoint.sh b/entrypoint.sh index 53b8fcc0..481e4c7d 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -68,6 +68,26 @@ if [[ "$INPUT_MARKDOWN_LINKS" == "true" ]]; then EXTRA_ARGS="${EXTRA_ARGS} --markdownLinks" fi +# repository +if [[ -n "$INPUT_REPOSITORY" ]]; then + EXTRA_ARGS="${EXTRA_ARGS} --repository=${INPUT_REPOSITORY}" +fi + +# token +if [[ -n "$INPUT_TOKEN" ]]; then + EXTRA_ARGS="${EXTRA_ARGS} --token=${INPUT_TOKEN}" +fi + +# use_code_blocks +if [[ "$INPUT_USE_CODE_BLOCKS" == "true" ]]; then + EXTRA_ARGS="${EXTRA_ARGS} --useCodeBlocks" +fi + +# use_major_version +if [[ "$INPUT_USE_MAJOR_VERSION" == "true" ]]; then + EXTRA_ARGS="${EXTRA_ARGS} --useMajorVersion" +fi + echo "::debug::Generating documentation using ${BIN_PATH}..." echo "::debug::Extra args: ${EXTRA_ARGS}" diff --git a/go.mod b/go.mod index fdaab85a..26ea7055 100644 --- a/go.mod +++ b/go.mod @@ -10,8 +10,10 @@ require ( require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/kr/pretty v0.2.0 // indirect - github.com/mattn/go-runewidth v0.0.9 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/rivo/uniseg v0.4.4 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) diff --git a/go.sum b/go.sum index c90e7623..765263b7 100644 --- a/go.sum +++ b/go.sum @@ -1,22 +1,33 @@ github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= +github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/types/action.go b/internal/types/action.go index 57a66e41..e35a0f47 100644 --- a/internal/types/action.go +++ b/internal/types/action.go @@ -267,9 +267,9 @@ func renderActionInputTableOutput(inputs map[string]ActionInput, inputColumns [] row = append(row, utils.FormatValue(inputs[key].Default)) case "Description": if inputs[key].DeprecationMessage != "" { - row = append(row, utils.WordWrap(fmt.Sprintf("**Deprecated:** %s", inputs[key].Description), maxWords)) + row = append(row, utils.WordWrap(fmt.Sprintf("**Deprecated:** %s", inputs[key].Description), maxWords, "
")) } else { - row = append(row, utils.WordWrap(inputs[key].Description, maxWords)) + row = append(row, utils.WordWrap(inputs[key].Description, maxWords, "
")) } default: return inputTableOutput, fmt.Errorf( @@ -308,7 +308,6 @@ func renderActionInputTableOutput(inputs map[string]ActionInput, inputColumns [] } // renderActionOutputTableOutput renders the action output table - func renderActionOutputTableOutput(outputs map[string]ActionOutput, outputColumns []string, markdownLinks bool, maxWidth int, maxWords int) (*strings.Builder, error) { outputTableOutput := &strings.Builder{} @@ -346,7 +345,7 @@ func renderActionOutputTableOutput(outputs map[string]ActionOutput, outputColumn case "Type": row = append(row, "string") case "Description": - row = append(row, utils.WordWrap(outputs[key].Description, maxWords)) + row = append(row, utils.WordWrap(outputs[key].Description, maxWords, "
")) default: return outputTableOutput, fmt.Errorf( "unknown outputs column: '%s'. Please specify any of the following columns: %s", @@ -369,7 +368,7 @@ func renderActionOutputTableOutput(outputs map[string]ActionOutput, outputColumn return outputTableOutput, err } } else { - _, err := fmt.Fprintln(outputTableOutput, internal.NoOutputsMessage) + _, err = fmt.Fprintln(outputTableOutput, internal.NoOutputsMessage) if err != nil { return outputTableOutput, err } @@ -379,5 +378,6 @@ func renderActionOutputTableOutput(outputs map[string]ActionOutput, outputColumn if err != nil { return outputTableOutput, err } + return outputTableOutput, nil } diff --git a/internal/types/code_block.go b/internal/types/code_block.go new file mode 100644 index 00000000..90816e27 --- /dev/null +++ b/internal/types/code_block.go @@ -0,0 +1,230 @@ +//Package types contains all defined types +/* +Copyright © 2021 Tonye Jack + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package types + +import ( + "bytes" + "fmt" + "os" + "regexp" + "sort" + "strconv" + "strings" + + "github.com/spf13/cobra" + "gopkg.in/yaml.v3" + + "github.com/tj-actions/auto-doc/v3/internal" + "github.com/tj-actions/auto-doc/v3/internal/utils" +) + +// CodeBlock represents the action.yml outputted as a code block +type CodeBlock struct { + Repository string + Token string + UseMajorVersion bool + OutputColumns []string + InputMarkdownLinks bool + ColMaxWidth string + ColMaxWords string + InputFileName string + OutputFileName string + Inputs map[string]ActionInput `yaml:"inputs,omitempty"` + Outputs map[string]ActionOutput `yaml:"outputs,omitempty"` +} + +// GetData parses the source yaml file +func (c *CodeBlock) GetData() error { + actionYaml, err := os.ReadFile(c.InputFileName) + // coverage:ignore + if err != nil { + return err + } + + err = yaml.Unmarshal(actionYaml, &c) + return err +} + +// writeDocumentation write the table to the output file +func (c *CodeBlock) writeDocumentation(inputCodeBlock, outputCodeBlock *strings.Builder) error { + var err error + input, err := os.ReadFile(c.OutputFileName) + // coverage:ignore + if err != nil { + return err + } + + var output []byte + + hasInputsData, indices := utils.HasBytesInBetween( + input, + []byte(internal.InputAutoDocStart), + []byte(internal.InputAutoDocEnd), + ) + + output = input + inputCodeBlockStr := strings.TrimSpace(inputCodeBlock.String()) + + if hasInputsData { + output = utils.ReplaceBytesInBetween(output, indices, []byte(inputCodeBlockStr)) + } else { + re := regexp.MustCompile(fmt.Sprintf("(?m)^%s", internal.InputsHeader)) + output = re.ReplaceAllFunc(input, func(match []byte) []byte { + if bytes.HasPrefix(match, []byte(internal.InputsHeader)) { + if inputCodeBlockStr != "" { + return []byte(fmt.Sprintf("%s\n\n%v", internal.InputsHeader, inputCodeBlockStr)) + } else { + return []byte(internal.InputsHeader) + } + } + return match + }) + } + + hasOutputsData, indices := utils.HasBytesInBetween( + output, + []byte(internal.OutputAutoDocStart), + []byte(internal.OutputAutoDocEnd), + ) + + outputCodeBlockStr := strings.TrimSpace(outputCodeBlock.String()) + + if hasOutputsData { + output = utils.ReplaceBytesInBetween(output, indices, []byte(outputCodeBlockStr)) + } else { + re := regexp.MustCompile(fmt.Sprintf("(?m)^%s", internal.OutputsHeader)) + output = re.ReplaceAllFunc(output, func(match []byte) []byte { + if bytes.HasPrefix(match, []byte(internal.OutputsHeader)) { + if outputCodeBlockStr != "" { + return []byte(fmt.Sprintf("%s\n\n%v", internal.OutputsHeader, outputCodeBlockStr)) + } else { + return []byte(internal.OutputsHeader) + } + } + return match + }) + } + + if err = os.WriteFile(c.OutputFileName, output, 0o666); err != nil { + cobra.CheckErr(err) + } + + return nil +} + +// getLatestTagForRepository returns the latest tag of a repository +func (c *CodeBlock) getLatestTagForRepository() (string, error) { + fmt.Println("Downloading the latest release") + + tag, err := utils.GetLatestRepositoryTag(c.Repository, c.Token, c.UseMajorVersion) + // coverage:ignore + if err != nil { + return "", err + } + + return tag, nil +} + +// renderCodeBlockActionInputs renders the inputs as a code block +func renderCodeBlockActionInputs(inputs map[string]ActionInput, repository, tag string) (*strings.Builder, error) { + // Output this as a code block + codeBlock := &strings.Builder{} + + _, err := fmt.Fprintln(codeBlock, internal.InputAutoDocStart) + // coverage:ignore + if err != nil { + return codeBlock, err + } + + keys := make([]string, 0, len(inputs)) + for k := range inputs { + keys = append(keys, k) + } + sort.Strings(keys) + + if len(keys) > 0 { + codeBlock.WriteString("```yaml\n") + codeBlock.WriteString(fmt.Sprintf("- uses: %s@%s\n", repository, tag)) + codeBlock.WriteString(fmt.Sprintf(" id: %s\n", strings.Split(repository, "/")[1])) + codeBlock.WriteString(" with:\n") + + for _, key := range keys { + codeBlock.WriteString(fmt.Sprintf(" # %s\n", utils.WordWrap(inputs[key].Description, 9, "\n # "))) + if inputs[key].Default != "" { + codeBlock.WriteString(fmt.Sprintf(" # Default: %s\n", inputs[key].Default)) + } + if inputs[key].DeprecationMessage != "" { + codeBlock.WriteString(fmt.Sprintf(" # Deprecated: %s\n", inputs[key].DeprecationMessage)) + } + codeBlock.WriteString(fmt.Sprintf(" %s: ''\n", key)) + codeBlock.WriteString("\n") + } + codeBlock.WriteString("```\n") + } else { + _, err := fmt.Fprintln(codeBlock, internal.NoInputsMessage) + if err != nil { + return codeBlock, err + } + } + + _, err = fmt.Fprintln(codeBlock, internal.InputAutoDocEnd) + // coverage:ignore + if err != nil { + return codeBlock, err + } + + return codeBlock, nil +} + +// RenderOutput renders the output and writes it to the given output +func (c *CodeBlock) RenderOutput() error { + maxWidth, err := strconv.Atoi(c.ColMaxWidth) + if err != nil { + return err + } + + maxWords, err := strconv.Atoi(c.ColMaxWords) + if err != nil { + return err + } + + tag, err := c.getLatestTagForRepository() + // coverage:ignore + if err != nil { + return err + } + + inputCodeBlockOutput, err := renderCodeBlockActionInputs(c.Inputs, c.Repository, tag) + + // coverage:ignore + if err != nil { + return err + } + + outputTableOutput, err := renderActionOutputTableOutput(c.Outputs, c.OutputColumns, c.InputMarkdownLinks, maxWidth, maxWords) + if err != nil { + return err + } + + err = c.writeDocumentation(inputCodeBlockOutput, outputTableOutput) + // coverage:ignore + if err != nil { + return err + } + + return nil +} diff --git a/internal/types/reusable.go b/internal/types/reusable.go index 7ba4c44b..3a142a07 100644 --- a/internal/types/reusable.go +++ b/internal/types/reusable.go @@ -261,9 +261,9 @@ func renderReusableInputTableOutput(inputs map[string]ReusableInput, inputColumn } case "Description": if inputs[key].DeprecationMessage != "" { - row = append(row, utils.WordWrap(fmt.Sprintf("**Deprecated:** %s", inputs[key].Description), maxWords)) + row = append(row, utils.WordWrap(fmt.Sprintf("**Deprecated:** %s", inputs[key].Description), maxWords, "
")) } else { - row = append(row, utils.WordWrap(inputs[key].Description, maxWords)) + row = append(row, utils.WordWrap(inputs[key].Description, maxWords, "
")) } default: return inputTableOutput, fmt.Errorf( @@ -338,7 +338,7 @@ func renderReusableOutputTableOutput(outputs map[string]ReusableOutput, reusable case "Value": row = append(row, utils.FormatValue(outputs[key].Value)) case "Description": - row = append(row, utils.WordWrap(outputs[key].Description, maxWords)) + row = append(row, utils.WordWrap(outputs[key].Description, maxWords, "
")) default: return outputTableOutput, fmt.Errorf( "unknown outputs column: '%s'. Please specify any of the following columns: %s", @@ -411,7 +411,7 @@ func renderReusableSecretTableOutput(secrets map[string]ReusableSecret, secretCo case "Required": row = append(row, fmt.Sprintf("%v", secrets[key].Required)) case "Description": - row = append(row, utils.WordWrap(secrets[key].Description, maxWords)) + row = append(row, utils.WordWrap(secrets[key].Description, maxWords, "
")) default: return secretTableOutput, fmt.Errorf( "unknown secrets column: '%secrets'. Please specify any of the following columns: %secrets", diff --git a/internal/utils/format_value.go b/internal/utils/format_value.go index 27a4b619..93bf94b9 100644 --- a/internal/utils/format_value.go +++ b/internal/utils/format_value.go @@ -23,7 +23,7 @@ import ( "github.com/tj-actions/auto-doc/v3/internal" ) -// FormatValue formats a string that would be outputed as markdown +// FormatValue formats a string that would be output as markdown func FormatValue(v string) string { if len(v) == 0 { return "" diff --git a/internal/utils/get_latest_repository_tag.go b/internal/utils/get_latest_repository_tag.go new file mode 100644 index 00000000..b94005bb --- /dev/null +++ b/internal/utils/get_latest_repository_tag.go @@ -0,0 +1,72 @@ +//Package utils is a package that contains all the utility functions +/* +Copyright © 2021 Tonye Jack + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package utils + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "strings" +) + +type Release struct { + TagName string `json:"tag_name"` +} + +// GetLatestRepositoryTag returns the latest tag of a repository +func GetLatestRepositoryTag(repository, token string, useMajorVersion bool) (string, error) { + url := fmt.Sprintf("https://api.github.com/repos/%s/releases/latest", repository) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return "", err + } + if token != "" { + req.Header.Set("Authorization", "token "+token) + } + + client := &http.Client{} + resp, err := client.Do(req) + if err != nil { + return "", err + } + defer func(Body io.ReadCloser) { + err := Body.Close() + if err != nil { + panic(err) + } + }(resp.Body) + + body, err := io.ReadAll(resp.Body) + if err != nil { + return "", err + } + + var release Release + err = json.Unmarshal(body, &release) + if err != nil { + return "", err + } + + version := release.TagName + + if useMajorVersion && strings.Contains(version, ".") { + version = strings.Split(version, ".")[0] + } + + return version, nil +} diff --git a/internal/utils/word_wrap.go b/internal/utils/word_wrap.go index 51a597d9..6a33c04d 100644 --- a/internal/utils/word_wrap.go +++ b/internal/utils/word_wrap.go @@ -22,8 +22,8 @@ import ( "unicode" ) -// WordWrap wraps text at the specified number of columns -func WordWrap(s string, limit int) string { +// WordWrap wraps text at the specified number of columns and inserts a line separator +func WordWrap(s string, limit int, lineSeparator string) string { if strings.TrimSpace(s) == "" || len(strings.Fields(s)) <= limit { return s } @@ -48,19 +48,19 @@ func WordWrap(s string, limit int) string { for len(strSlice) >= 1 { // convert slice/array back to string - // but insert
at specified limit + // but insert line break at specified limit if len(strSlice) < limit { limit = len(strSlice) } - result = result + strings.Join(strSlice[:limit], " ") + "
" + result = result + strings.Join(strSlice[:limit], " ") + " " + lineSeparator // discard the elements that were copied over to result strSlice = strSlice[limit:] } // Trim the last
tag - result = strings.TrimSuffix(result, "
") + result = strings.TrimSuffix(result, lineSeparator) return result } diff --git a/test/README-codeBlocks.md b/test/README-codeBlocks.md new file mode 100644 index 00000000..127fdfb5 --- /dev/null +++ b/test/README-codeBlocks.md @@ -0,0 +1,173 @@ +## Inputs + + +```yaml +- uses: tj-actions/changed-files@v40.1.1 + id: changed-files + with: + # Specify a different base commit SHA used for comparing + # changes + base_sha: '' + + # Exclude changes outside the current directory and show path + # names relative to it. **NOTE:** This requires you to + # specify the top level directory via the `path` input. + diff_relative: '' + + # Output unique changed directories instead of filenames. **NOTE:** This + # returns `.` for changed files located in the root + # of the project. + # Default: false + dir_names: '' + + # Maximum depth of directories to output. e.g `test/test1/test2` with + # max depth of `2` returns `test/test1`. + dir_names_max_depth: '' + + # Depth of additional branch history fetched. **NOTE**: This can + # be adjusted to resolve errors with insufficient history. + # Default: 50 + fetch_depth: '' + + # File and directory patterns to detect changes using only + # these list of file(s) (Defaults to the entire repo) **NOTE:** Multiline file/directory patterns + # should not include quotes. + files: '' + + # Source file(s) used to populate the `files` input. + files_from_source_file: '' + + # Ignore changes to these file(s) **NOTE:** Multiline file/directory patterns + # should not include quotes. + files_ignore: '' + + # Source file(s) used to populate the `files_ignore` input + files_ignore_from_source_file: '' + + # Separator used to split the `files_ignore` input + # Default: + + files_ignore_separator: '' + + # Separator used to split the `files` input + # Default: + + files_separator: '' + + # Include `all_old_new_renamed_files` output. Note this can generate a large + # output See: [#501](https://github.com/tj-actions/changed-files/issues/501). + # Default: false + include_all_old_new_renamed_files: '' + + # Output list of changed files in a JSON formatted + # string which can be used for matrix jobs. + # Default: false + json: '' + + # Output list of changed files in a raw format + # which means that the output will not be surrounded + # by quotes and special characters will not be escaped. + # Default: false + # Deprecated: Use `json_unescaped` instead. + json_raw_format: '' + + # Output list of changed files in a JSON formatted + # string without escaping special characters. + # Default: false + json_unescaped: '' + + # Boolean indicating whether to output input, output and secret + # names as markdown links + # Default: false + markdown_links: '' + + # Indicates whether to include match directories + # Default: true + match_directories: '' + + # Split character for old and new renamed filename pairs. + # Default: + old_new_files_separator: '' + + # Split character for old and new filename pairs. + # Default: , + old_new_separator: '' + + # Directory to store output files. + # Default: .github/outputs + output_dir: '' + + # Specify a relative path under `$GITHUB_WORKSPACE` to locate the + # repository. + # Default: . + path: '' + + # Use non ascii characters to match files and output + # the filenames completely verbatim by setting this to `false` + # Default: true + quotepath: '' + + # Split character for output strings. + # Default: + separator: '' + + # Specify a different commit SHA used for comparing changes + sha: '' + + # Get changed files for commits whose timestamp is older + # than the given time. + since: '' + + # Use the last commit on the remote branch as + # the `base_sha`. Defaults to the last non merge commit + # on the target branch for pull request events and + # the previous remote commit of the current branch for + # push events. + # Default: false + since_last_remote_commit: '' + + # The GitHub token to use for authentication. + # Default: ${{ github.token }} + token: '' + + # Get changed files for commits whose timestamp is earlier + # than the given time. + until: '' + + # Write outputs to files in the `.github/outputs` folder by + # default. + # Default: false + write_output_files: '' + +``` + + +## Outputs + + + +| OUTPUT | TYPE | DESCRIPTION | +|--------------------------------|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| added_files | string | Returns only files that are Added
(A). | +| all_changed_and_modified_files | string | Returns all changed and modified files
i.e. *a combination of (ACMRDTUX)* | +| all_changed_files | string | Returns all changed files i.e. *a combination of all added, copied, modified and renamed files (ACMR)* | +| all_modified_files | string | Returns all changed files i.e. *a combination of all added, copied, modified, renamed and deleted files (ACMRD)*. | +| all_old_new_renamed_files | string | Returns only files that are Renamed
and list their old and new
names. **NOTE:** This requires setting `include_all_old_new_renamed_files`
to `true` (R) | +| any_changed | string | Returns `true` when any of the
filenames provided using the `files` input
has changed. If no `files` have
been specified,an empty string `''` is
returned. i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*. | +| any_deleted | string | Returns `true` when any of the
filenames provided using the `files` input
has been deleted. If no `files`
have been specified,an empty string `''`
is returned. (D) | +| any_modified | string | Returns `true` when any of the
filenames provided using the `files` input
has been modified. If no `files`
have been specified,an empty string `''`
is returned. i.e. *using a combination of all added, copied, modified, renamed, and deleted files (ACMRD)*. | +| copied_files | string | Returns only files that are Copied
(C). | +| deleted_files | string | Returns only files that are Deleted
(D). | +| modified_files | string | Returns only files that are Modified
(M). | +| only_changed | string | Returns `true` when only files provided
using the `files` input has changed.
If no `files` have been specified,an
empty string `''` is returned. i.e.
*using a combination of all added, copied, modified and renamed files (ACMR)*. | +| only_deleted | string | Returns `true` when only files provided
using the `files` input has been
deleted. If no `files` have been
specified,an empty string `''` is returned.
(D) | +| only_modified | string | Returns `true` when only files provided
using the `files` input has been
modified. If no `files` have been
specified,an empty string `''` is returned.(ACMRD). | +| other_changed_files | string | Returns all other changed files not
listed in the files input i.e.
*using a combination of all added, copied, modified and renamed files (ACMR)*. | +| other_deleted_files | string | Returns all other deleted files not
listed in the files input i.e.
*a combination of all deleted files (D)* | +| other_modified_files | string | Returns all other modified files not
listed in the files input i.e.
*a combination of all added, copied, modified, and deleted files (ACMRD)* | +| renamed_files | string | Returns only files that are Renamed
(R). | +| type_changed_files | string | Returns only files that have their
file type changed (T). | +| unknown_files | string | Returns only files that are Unknown
(X). | +| unmerged_files | string | Returns only files that are Unmerged
(U). | + + diff --git a/test/README-codeBlocksMajorVersion.md b/test/README-codeBlocksMajorVersion.md new file mode 100644 index 00000000..4aab00f0 --- /dev/null +++ b/test/README-codeBlocksMajorVersion.md @@ -0,0 +1,143 @@ +## Inputs + + +```yaml +- uses: tj-actions/changed-files@v40 + id: changed-files + with: + # Specify a different base commit SHA used for comparing + # changes + base_sha: '' + + # Exclude changes outside the current directory and show path + # names relative to it. **NOTE:** This requires you to + # specify the top level directory via the `path` input. + diff_relative: '' + + # Output unique changed directories instead of filenames. **NOTE:** This + # returns `.` for changed files located in the root + # of the project. + # Default: false + dir_names: '' + + # Maximum depth of directories to output. e.g `test/test1/test2` with + # max depth of `2` returns `test/test1`. + dir_names_max_depth: '' + + # Depth of additional branch history fetched. **NOTE**: This can + # be adjusted to resolve errors with insufficient history. + # Default: 50 + fetch_depth: '' + + # File and directory patterns to detect changes using only + # these list of file(s) (Defaults to the entire repo) **NOTE:** Multiline file/directory patterns + # should not include quotes. + files: '' + + # Source file(s) used to populate the `files` input. + files_from_source_file: '' + + # Ignore changes to these file(s) **NOTE:** Multiline file/directory patterns + # should not include quotes. + files_ignore: '' + + # Source file(s) used to populate the `files_ignore` input + files_ignore_from_source_file: '' + + # Separator used to split the `files_ignore` input + # Default: + + files_ignore_separator: '' + + # Separator used to split the `files` input + # Default: + + files_separator: '' + + # Include `all_old_new_renamed_files` output. Note this can generate a large + # output See: [#501](https://github.com/tj-actions/changed-files/issues/501). + # Default: false + include_all_old_new_renamed_files: '' + + # Output list of changed files in a JSON formatted + # string which can be used for matrix jobs. + # Default: false + json: '' + + # Output list of changed files in a raw format + # which means that the output will not be surrounded + # by quotes and special characters will not be escaped. + # Default: false + # Deprecated: Use `json_unescaped` instead. + json_raw_format: '' + + # Output list of changed files in a JSON formatted + # string without escaping special characters. + # Default: false + json_unescaped: '' + + # Boolean indicating whether to output input, output and secret + # names as markdown links + # Default: false + markdown_links: '' + + # Indicates whether to include match directories + # Default: true + match_directories: '' + + # Split character for old and new renamed filename pairs. + # Default: + old_new_files_separator: '' + + # Split character for old and new filename pairs. + # Default: , + old_new_separator: '' + + # Directory to store output files. + # Default: .github/outputs + output_dir: '' + + # Specify a relative path under `$GITHUB_WORKSPACE` to locate the + # repository. + # Default: . + path: '' + + # Use non ascii characters to match files and output + # the filenames completely verbatim by setting this to `false` + # Default: true + quotepath: '' + + # Split character for output strings. + # Default: + separator: '' + + # Specify a different commit SHA used for comparing changes + sha: '' + + # Get changed files for commits whose timestamp is older + # than the given time. + since: '' + + # Use the last commit on the remote branch as + # the `base_sha`. Defaults to the last non merge commit + # on the target branch for pull request events and + # the previous remote commit of the current branch for + # push events. + # Default: false + since_last_remote_commit: '' + + # The GitHub token to use for authentication. + # Default: ${{ github.token }} + token: '' + + # Get changed files for commits whose timestamp is earlier + # than the given time. + until: '' + + # Write outputs to files in the `.github/outputs` folder by + # default. + # Default: false + write_output_files: '' + +``` + diff --git a/test/README-inputColumns.md b/test/README-inputColumns.md index df4d198f..c4a369dd 100644 --- a/test/README-inputColumns.md +++ b/test/README-inputColumns.md @@ -32,6 +32,7 @@ | sha | string | Specify a different commit SHA used
for comparing changes | | since | string | Get changed files for commits whose
timestamp is older than the given
time. | | since_last_remote_commit | string | Use the last commit on the
remote branch as the `base_sha`. Defaults
to the last non merge commit
on the target branch for pull
request events and the previous remote
commit of the current branch for
push events. | +| token | string | The GitHub token to use for
authentication. | | until | string | Get changed files for commits whose
timestamp is earlier than the given
time. | | write_output_files | string | Write outputs to files in the
`.github/outputs` folder by default. | diff --git a/test/README-markdownLinks.md b/test/README-markdownLinks.md index 5974564b..076107c2 100644 --- a/test/README-markdownLinks.md +++ b/test/README-markdownLinks.md @@ -4,36 +4,37 @@ -| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION | -|-------------------------------------------------------------------------------------------------------------------------------------|--------|----------|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [base_sha](#input_base_sha) | string | false | | Specify a different base commit SHA
used for comparing changes | -| [diff_relative](#input_diff_relative) | string | false | | Exclude changes outside the current directory
and show path names relative to
it. **NOTE:** This requires you to
specify the top level directory via
the `path` input. | -| [dir_names](#input_dir_names) | string | false | `"false"` | Output unique changed directories instead of
filenames. **NOTE:** This returns `.` for
changed files located in the root
of the project. | -| [dir_names_max_depth](#input_dir_names_max_depth) | string | false | | Maximum depth of directories to output.
e.g `test/test1/test2` with max depth of
`2` returns `test/test1`. | -| [fetch_depth](#input_fetch_depth) | string | false | `"50"` | Depth of additional branch history fetched.
**NOTE**: This can be adjusted to
resolve errors with insufficient history. | -| [files](#input_files) | string | false | | File and directory patterns to detect
changes using only these list of
file(s) (Defaults to the entire repo) **NOTE:** Multiline file/directory patterns
should not include quotes. | -| [files_from_source_file](#input_files_from_source_file) | string | false | | Source file(s) used to populate the
`files` input. | -| [files_ignore](#input_files_ignore) | string | false | | Ignore changes to these file(s) **NOTE:**
Multiline file/directory patterns should not include
quotes. | -| [files_ignore_from_source_file](#input_files_ignore_from_source_file) | string | false | | Source file(s) used to populate the
`files_ignore` input | -| [files_ignore_separator](#input_files_ignore_separator) | string | false | `"\n"` | Separator used to split the `files_ignore`
input | -| [files_separator](#input_files_separator) | string | false | `"\n"` | Separator used to split the `files`
input | -| [include_all_old_new_renamed_files](#input_include_all_old_new_renamed_files) | string | false | `"false"` | Include `all_old_new_renamed_files` output. Note this can
generate a large output See: [#501](https://github.com/tj-actions/changed-files/issues/501). | -| [json](#input_json) | string | false | `"false"` | Output list of changed files in
a JSON formatted string which can
be used for matrix jobs. | -| ~~[json_raw_format](#input_json_raw_format)~~
Use `json_unescaped` instead. | string | false | `"false"` | **Deprecated:** Output list of changed files
in a raw format which means
that the output will not be
surrounded by quotes and special characters
will not be escaped. | -| [json_unescaped](#input_json_unescaped) | string | false | `"false"` | Output list of changed files in
a JSON formatted string without escaping
special characters. | -| [markdown_links](#input_markdown_links) | string | false | `"false"` | Boolean indicating whether to output input,
output and secret names as markdown
links | -| [match_directories](#input_match_directories) | string | false | `"true"` | Indicates whether to include match directories | -| [old_new_files_separator](#input_old_new_files_separator) | string | false | `" "` | Split character for old and new
renamed filename pairs. | -| [old_new_separator](#input_old_new_separator) | string | false | `","` | Split character for old and new
filename pairs. | -| [output_dir](#input_output_dir) | string | false | `".github/outputs"` | Directory to store output files. | -| [path](#input_path) | string | false | `"."` | Specify a relative path under `$GITHUB_WORKSPACE`
to locate the repository. | -| [quotepath](#input_quotepath) | string | false | `"true"` | Use non ascii characters to match
files and output the filenames completely
verbatim by setting this to `false` | -| [separator](#input_separator) | string | false | `" "` | Split character for output strings. | -| [sha](#input_sha) | string | false | | Specify a different commit SHA used
for comparing changes | -| [since](#input_since) | string | false | | Get changed files for commits whose
timestamp is older than the given
time. | -| [since_last_remote_commit](#input_since_last_remote_commit) | string | true | `"false"` | Use the last commit on the
remote branch as the `base_sha`. Defaults
to the last non merge commit
on the target branch for pull
request events and the previous remote
commit of the current branch for
push events. | -| [until](#input_until) | string | false | | Get changed files for commits whose
timestamp is earlier than the given
time. | -| [write_output_files](#input_write_output_files) | string | false | `"false"` | Write outputs to files in the
`.github/outputs` folder by default. | +| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION | +|-------------------------------------------------------------------------------------------------------------------------------------|--------|----------|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [base_sha](#input_base_sha) | string | false | | Specify a different base commit SHA
used for comparing changes | +| [diff_relative](#input_diff_relative) | string | false | | Exclude changes outside the current directory
and show path names relative to
it. **NOTE:** This requires you to
specify the top level directory via
the `path` input. | +| [dir_names](#input_dir_names) | string | false | `"false"` | Output unique changed directories instead of
filenames. **NOTE:** This returns `.` for
changed files located in the root
of the project. | +| [dir_names_max_depth](#input_dir_names_max_depth) | string | false | | Maximum depth of directories to output.
e.g `test/test1/test2` with max depth of
`2` returns `test/test1`. | +| [fetch_depth](#input_fetch_depth) | string | false | `"50"` | Depth of additional branch history fetched.
**NOTE**: This can be adjusted to
resolve errors with insufficient history. | +| [files](#input_files) | string | false | | File and directory patterns to detect
changes using only these list of
file(s) (Defaults to the entire repo) **NOTE:** Multiline file/directory patterns
should not include quotes. | +| [files_from_source_file](#input_files_from_source_file) | string | false | | Source file(s) used to populate the
`files` input. | +| [files_ignore](#input_files_ignore) | string | false | | Ignore changes to these file(s) **NOTE:**
Multiline file/directory patterns should not include
quotes. | +| [files_ignore_from_source_file](#input_files_ignore_from_source_file) | string | false | | Source file(s) used to populate the
`files_ignore` input | +| [files_ignore_separator](#input_files_ignore_separator) | string | false | `"\n"` | Separator used to split the `files_ignore`
input | +| [files_separator](#input_files_separator) | string | false | `"\n"` | Separator used to split the `files`
input | +| [include_all_old_new_renamed_files](#input_include_all_old_new_renamed_files) | string | false | `"false"` | Include `all_old_new_renamed_files` output. Note this can
generate a large output See: [#501](https://github.com/tj-actions/changed-files/issues/501). | +| [json](#input_json) | string | false | `"false"` | Output list of changed files in
a JSON formatted string which can
be used for matrix jobs. | +| ~~[json_raw_format](#input_json_raw_format)~~
Use `json_unescaped` instead. | string | false | `"false"` | **Deprecated:** Output list of changed files
in a raw format which means
that the output will not be
surrounded by quotes and special characters
will not be escaped. | +| [json_unescaped](#input_json_unescaped) | string | false | `"false"` | Output list of changed files in
a JSON formatted string without escaping
special characters. | +| [markdown_links](#input_markdown_links) | string | false | `"false"` | Boolean indicating whether to output input,
output and secret names as markdown
links | +| [match_directories](#input_match_directories) | string | false | `"true"` | Indicates whether to include match directories | +| [old_new_files_separator](#input_old_new_files_separator) | string | false | `" "` | Split character for old and new
renamed filename pairs. | +| [old_new_separator](#input_old_new_separator) | string | false | `","` | Split character for old and new
filename pairs. | +| [output_dir](#input_output_dir) | string | false | `".github/outputs"` | Directory to store output files. | +| [path](#input_path) | string | false | `"."` | Specify a relative path under `$GITHUB_WORKSPACE`
to locate the repository. | +| [quotepath](#input_quotepath) | string | false | `"true"` | Use non ascii characters to match
files and output the filenames completely
verbatim by setting this to `false` | +| [separator](#input_separator) | string | false | `" "` | Split character for output strings. | +| [sha](#input_sha) | string | false | | Specify a different commit SHA used
for comparing changes | +| [since](#input_since) | string | false | | Get changed files for commits whose
timestamp is older than the given
time. | +| [since_last_remote_commit](#input_since_last_remote_commit) | string | true | `"false"` | Use the last commit on the
remote branch as the `base_sha`. Defaults
to the last non merge commit
on the target branch for pull
request events and the previous remote
commit of the current branch for
push events. | +| [token](#input_token) | string | false | `"${{ github.token }}"` | The GitHub token to use for
authentication. | +| [until](#input_until) | string | false | | Get changed files for commits whose
timestamp is earlier than the given
time. | +| [write_output_files](#input_write_output_files) | string | false | `"false"` | Write outputs to files in the
`.github/outputs` folder by default. | diff --git a/test/README-outputColumns.md b/test/README-outputColumns.md index 9f6a63c9..5808c102 100644 --- a/test/README-outputColumns.md +++ b/test/README-outputColumns.md @@ -4,36 +4,37 @@ -| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION | -|--------------------------------------------------------|--------|----------|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| base_sha | string | false | | Specify a different base commit SHA
used for comparing changes | -| diff_relative | string | false | | Exclude changes outside the current directory
and show path names relative to
it. **NOTE:** This requires you to
specify the top level directory via
the `path` input. | -| dir_names | string | false | `"false"` | Output unique changed directories instead of
filenames. **NOTE:** This returns `.` for
changed files located in the root
of the project. | -| dir_names_max_depth | string | false | | Maximum depth of directories to output.
e.g `test/test1/test2` with max depth of
`2` returns `test/test1`. | -| fetch_depth | string | false | `"50"` | Depth of additional branch history fetched.
**NOTE**: This can be adjusted to
resolve errors with insufficient history. | -| files | string | false | | File and directory patterns to detect
changes using only these list of
file(s) (Defaults to the entire repo) **NOTE:** Multiline file/directory patterns
should not include quotes. | -| files_from_source_file | string | false | | Source file(s) used to populate the
`files` input. | -| files_ignore | string | false | | Ignore changes to these file(s) **NOTE:**
Multiline file/directory patterns should not include
quotes. | -| files_ignore_from_source_file | string | false | | Source file(s) used to populate the
`files_ignore` input | -| files_ignore_separator | string | false | `"\n"` | Separator used to split the `files_ignore`
input | -| files_separator | string | false | `"\n"` | Separator used to split the `files`
input | -| include_all_old_new_renamed_files | string | false | `"false"` | Include `all_old_new_renamed_files` output. Note this can
generate a large output See: [#501](https://github.com/tj-actions/changed-files/issues/501). | -| json | string | false | `"false"` | Output list of changed files in
a JSON formatted string which can
be used for matrix jobs. | -| ~~json_raw_format~~
Use `json_unescaped` instead. | string | false | `"false"` | **Deprecated:** Output list of changed files
in a raw format which means
that the output will not be
surrounded by quotes and special characters
will not be escaped. | -| json_unescaped | string | false | `"false"` | Output list of changed files in
a JSON formatted string without escaping
special characters. | -| markdown_links | string | false | `"false"` | Boolean indicating whether to output input,
output and secret names as markdown
links | -| match_directories | string | false | `"true"` | Indicates whether to include match directories | -| old_new_files_separator | string | false | `" "` | Split character for old and new
renamed filename pairs. | -| old_new_separator | string | false | `","` | Split character for old and new
filename pairs. | -| output_dir | string | false | `".github/outputs"` | Directory to store output files. | -| path | string | false | `"."` | Specify a relative path under `$GITHUB_WORKSPACE`
to locate the repository. | -| quotepath | string | false | `"true"` | Use non ascii characters to match
files and output the filenames completely
verbatim by setting this to `false` | -| separator | string | false | `" "` | Split character for output strings. | -| sha | string | false | | Specify a different commit SHA used
for comparing changes | -| since | string | false | | Get changed files for commits whose
timestamp is older than the given
time. | -| since_last_remote_commit | string | true | `"false"` | Use the last commit on the
remote branch as the `base_sha`. Defaults
to the last non merge commit
on the target branch for pull
request events and the previous remote
commit of the current branch for
push events. | -| until | string | false | | Get changed files for commits whose
timestamp is earlier than the given
time. | -| write_output_files | string | false | `"false"` | Write outputs to files in the
`.github/outputs` folder by default. | +| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION | +|--------------------------------------------------------|--------|----------|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| base_sha | string | false | | Specify a different base commit SHA
used for comparing changes | +| diff_relative | string | false | | Exclude changes outside the current directory
and show path names relative to
it. **NOTE:** This requires you to
specify the top level directory via
the `path` input. | +| dir_names | string | false | `"false"` | Output unique changed directories instead of
filenames. **NOTE:** This returns `.` for
changed files located in the root
of the project. | +| dir_names_max_depth | string | false | | Maximum depth of directories to output.
e.g `test/test1/test2` with max depth of
`2` returns `test/test1`. | +| fetch_depth | string | false | `"50"` | Depth of additional branch history fetched.
**NOTE**: This can be adjusted to
resolve errors with insufficient history. | +| files | string | false | | File and directory patterns to detect
changes using only these list of
file(s) (Defaults to the entire repo) **NOTE:** Multiline file/directory patterns
should not include quotes. | +| files_from_source_file | string | false | | Source file(s) used to populate the
`files` input. | +| files_ignore | string | false | | Ignore changes to these file(s) **NOTE:**
Multiline file/directory patterns should not include
quotes. | +| files_ignore_from_source_file | string | false | | Source file(s) used to populate the
`files_ignore` input | +| files_ignore_separator | string | false | `"\n"` | Separator used to split the `files_ignore`
input | +| files_separator | string | false | `"\n"` | Separator used to split the `files`
input | +| include_all_old_new_renamed_files | string | false | `"false"` | Include `all_old_new_renamed_files` output. Note this can
generate a large output See: [#501](https://github.com/tj-actions/changed-files/issues/501). | +| json | string | false | `"false"` | Output list of changed files in
a JSON formatted string which can
be used for matrix jobs. | +| ~~json_raw_format~~
Use `json_unescaped` instead. | string | false | `"false"` | **Deprecated:** Output list of changed files
in a raw format which means
that the output will not be
surrounded by quotes and special characters
will not be escaped. | +| json_unescaped | string | false | `"false"` | Output list of changed files in
a JSON formatted string without escaping
special characters. | +| markdown_links | string | false | `"false"` | Boolean indicating whether to output input,
output and secret names as markdown
links | +| match_directories | string | false | `"true"` | Indicates whether to include match directories | +| old_new_files_separator | string | false | `" "` | Split character for old and new
renamed filename pairs. | +| old_new_separator | string | false | `","` | Split character for old and new
filename pairs. | +| output_dir | string | false | `".github/outputs"` | Directory to store output files. | +| path | string | false | `"."` | Specify a relative path under `$GITHUB_WORKSPACE`
to locate the repository. | +| quotepath | string | false | `"true"` | Use non ascii characters to match
files and output the filenames completely
verbatim by setting this to `false` | +| separator | string | false | `" "` | Split character for output strings. | +| sha | string | false | | Specify a different commit SHA used
for comparing changes | +| since | string | false | | Get changed files for commits whose
timestamp is older than the given
time. | +| since_last_remote_commit | string | true | `"false"` | Use the last commit on the
remote branch as the `base_sha`. Defaults
to the last non merge commit
on the target branch for pull
request events and the previous remote
commit of the current branch for
push events. | +| token | string | false | `"${{ github.token }}"` | The GitHub token to use for
authentication. | +| until | string | false | | Get changed files for commits whose
timestamp is earlier than the given
time. | +| write_output_files | string | false | `"false"` | Write outputs to files in the
`.github/outputs` folder by default. | diff --git a/test/README.md b/test/README.md index 349c3746..4538dc8a 100644 --- a/test/README.md +++ b/test/README.md @@ -6,36 +6,37 @@ Test text ## Inputs -| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION | -|--------------------------------------------------------|--------|----------|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| base_sha | string | false | | Specify a different base commit SHA
used for comparing changes | -| diff_relative | string | false | | Exclude changes outside the current directory
and show path names relative to
it. **NOTE:** This requires you to
specify the top level directory via
the `path` input. | -| dir_names | string | false | `"false"` | Output unique changed directories instead of
filenames. **NOTE:** This returns `.` for
changed files located in the root
of the project. | -| dir_names_max_depth | string | false | | Maximum depth of directories to output.
e.g `test/test1/test2` with max depth of
`2` returns `test/test1`. | -| fetch_depth | string | false | `"50"` | Depth of additional branch history fetched.
**NOTE**: This can be adjusted to
resolve errors with insufficient history. | -| files | string | false | | File and directory patterns to detect
changes using only these list of
file(s) (Defaults to the entire repo) **NOTE:** Multiline file/directory patterns
should not include quotes. | -| files_from_source_file | string | false | | Source file(s) used to populate the
`files` input. | -| files_ignore | string | false | | Ignore changes to these file(s) **NOTE:**
Multiline file/directory patterns should not include
quotes. | -| files_ignore_from_source_file | string | false | | Source file(s) used to populate the
`files_ignore` input | -| files_ignore_separator | string | false | `"\n"` | Separator used to split the `files_ignore`
input | -| files_separator | string | false | `"\n"` | Separator used to split the `files`
input | -| include_all_old_new_renamed_files | string | false | `"false"` | Include `all_old_new_renamed_files` output. Note this can
generate a large output See: [#501](https://github.com/tj-actions/changed-files/issues/501). | -| json | string | false | `"false"` | Output list of changed files in
a JSON formatted string which can
be used for matrix jobs. | -| ~~json_raw_format~~
Use `json_unescaped` instead. | string | false | `"false"` | **Deprecated:** Output list of changed files
in a raw format which means
that the output will not be
surrounded by quotes and special characters
will not be escaped. | -| json_unescaped | string | false | `"false"` | Output list of changed files in
a JSON formatted string without escaping
special characters. | -| markdown_links | string | false | `"false"` | Boolean indicating whether to output input,
output and secret names as markdown
links | -| match_directories | string | false | `"true"` | Indicates whether to include match directories | -| old_new_files_separator | string | false | `" "` | Split character for old and new
renamed filename pairs. | -| old_new_separator | string | false | `","` | Split character for old and new
filename pairs. | -| output_dir | string | false | `".github/outputs"` | Directory to store output files. | -| path | string | false | `"."` | Specify a relative path under `$GITHUB_WORKSPACE`
to locate the repository. | -| quotepath | string | false | `"true"` | Use non ascii characters to match
files and output the filenames completely
verbatim by setting this to `false` | -| separator | string | false | `" "` | Split character for output strings. | -| sha | string | false | | Specify a different commit SHA used
for comparing changes | -| since | string | false | | Get changed files for commits whose
timestamp is older than the given
time. | -| since_last_remote_commit | string | true | `"false"` | Use the last commit on the
remote branch as the `base_sha`. Defaults
to the last non merge commit
on the target branch for pull
request events and the previous remote
commit of the current branch for
push events. | -| until | string | false | | Get changed files for commits whose
timestamp is earlier than the given
time. | -| write_output_files | string | false | `"false"` | Write outputs to files in the
`.github/outputs` folder by default. | +| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION | +|--------------------------------------------------------|--------|----------|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| base_sha | string | false | | Specify a different base commit SHA
used for comparing changes | +| diff_relative | string | false | | Exclude changes outside the current directory
and show path names relative to
it. **NOTE:** This requires you to
specify the top level directory via
the `path` input. | +| dir_names | string | false | `"false"` | Output unique changed directories instead of
filenames. **NOTE:** This returns `.` for
changed files located in the root
of the project. | +| dir_names_max_depth | string | false | | Maximum depth of directories to output.
e.g `test/test1/test2` with max depth of
`2` returns `test/test1`. | +| fetch_depth | string | false | `"50"` | Depth of additional branch history fetched.
**NOTE**: This can be adjusted to
resolve errors with insufficient history. | +| files | string | false | | File and directory patterns to detect
changes using only these list of
file(s) (Defaults to the entire repo) **NOTE:** Multiline file/directory patterns
should not include quotes. | +| files_from_source_file | string | false | | Source file(s) used to populate the
`files` input. | +| files_ignore | string | false | | Ignore changes to these file(s) **NOTE:**
Multiline file/directory patterns should not include
quotes. | +| files_ignore_from_source_file | string | false | | Source file(s) used to populate the
`files_ignore` input | +| files_ignore_separator | string | false | `"\n"` | Separator used to split the `files_ignore`
input | +| files_separator | string | false | `"\n"` | Separator used to split the `files`
input | +| include_all_old_new_renamed_files | string | false | `"false"` | Include `all_old_new_renamed_files` output. Note this can
generate a large output See: [#501](https://github.com/tj-actions/changed-files/issues/501). | +| json | string | false | `"false"` | Output list of changed files in
a JSON formatted string which can
be used for matrix jobs. | +| ~~json_raw_format~~
Use `json_unescaped` instead. | string | false | `"false"` | **Deprecated:** Output list of changed files
in a raw format which means
that the output will not be
surrounded by quotes and special characters
will not be escaped. | +| json_unescaped | string | false | `"false"` | Output list of changed files in
a JSON formatted string without escaping
special characters. | +| markdown_links | string | false | `"false"` | Boolean indicating whether to output input,
output and secret names as markdown
links | +| match_directories | string | false | `"true"` | Indicates whether to include match directories | +| old_new_files_separator | string | false | `" "` | Split character for old and new
renamed filename pairs. | +| old_new_separator | string | false | `","` | Split character for old and new
filename pairs. | +| output_dir | string | false | `".github/outputs"` | Directory to store output files. | +| path | string | false | `"."` | Specify a relative path under `$GITHUB_WORKSPACE`
to locate the repository. | +| quotepath | string | false | `"true"` | Use non ascii characters to match
files and output the filenames completely
verbatim by setting this to `false` | +| separator | string | false | `" "` | Split character for output strings. | +| sha | string | false | | Specify a different commit SHA used
for comparing changes | +| since | string | false | | Get changed files for commits whose
timestamp is older than the given
time. | +| since_last_remote_commit | string | true | `"false"` | Use the last commit on the
remote branch as the `base_sha`. Defaults
to the last non merge commit
on the target branch for pull
request events and the previous remote
commit of the current branch for
push events. | +| token | string | false | `"${{ github.token }}"` | The GitHub token to use for
authentication. | +| until | string | false | | Get changed files for commits whose
timestamp is earlier than the given
time. | +| write_output_files | string | false | `"false"` | Write outputs to files in the
`.github/outputs` folder by default. | @@ -43,36 +44,37 @@ Test text ## Inputs -| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION | -|--------------------------------------------------------|--------|----------|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| base_sha | string | false | | Specify a different base commit SHA
used for comparing changes | -| diff_relative | string | false | | Exclude changes outside the current directory
and show path names relative to
it. **NOTE:** This requires you to
specify the top level directory via
the `path` input. | -| dir_names | string | false | `"false"` | Output unique changed directories instead of
filenames. **NOTE:** This returns `.` for
changed files located in the root
of the project. | -| dir_names_max_depth | string | false | | Maximum depth of directories to output.
e.g `test/test1/test2` with max depth of
`2` returns `test/test1`. | -| fetch_depth | string | false | `"50"` | Depth of additional branch history fetched.
**NOTE**: This can be adjusted to
resolve errors with insufficient history. | -| files | string | false | | File and directory patterns to detect
changes using only these list of
file(s) (Defaults to the entire repo) **NOTE:** Multiline file/directory patterns
should not include quotes. | -| files_from_source_file | string | false | | Source file(s) used to populate the
`files` input. | -| files_ignore | string | false | | Ignore changes to these file(s) **NOTE:**
Multiline file/directory patterns should not include
quotes. | -| files_ignore_from_source_file | string | false | | Source file(s) used to populate the
`files_ignore` input | -| files_ignore_separator | string | false | `"\n"` | Separator used to split the `files_ignore`
input | -| files_separator | string | false | `"\n"` | Separator used to split the `files`
input | -| include_all_old_new_renamed_files | string | false | `"false"` | Include `all_old_new_renamed_files` output. Note this can
generate a large output See: [#501](https://github.com/tj-actions/changed-files/issues/501). | -| json | string | false | `"false"` | Output list of changed files in
a JSON formatted string which can
be used for matrix jobs. | -| ~~json_raw_format~~
Use `json_unescaped` instead. | string | false | `"false"` | **Deprecated:** Output list of changed files
in a raw format which means
that the output will not be
surrounded by quotes and special characters
will not be escaped. | -| json_unescaped | string | false | `"false"` | Output list of changed files in
a JSON formatted string without escaping
special characters. | -| markdown_links | string | false | `"false"` | Boolean indicating whether to output input,
output and secret names as markdown
links | -| match_directories | string | false | `"true"` | Indicates whether to include match directories | -| old_new_files_separator | string | false | `" "` | Split character for old and new
renamed filename pairs. | -| old_new_separator | string | false | `","` | Split character for old and new
filename pairs. | -| output_dir | string | false | `".github/outputs"` | Directory to store output files. | -| path | string | false | `"."` | Specify a relative path under `$GITHUB_WORKSPACE`
to locate the repository. | -| quotepath | string | false | `"true"` | Use non ascii characters to match
files and output the filenames completely
verbatim by setting this to `false` | -| separator | string | false | `" "` | Split character for output strings. | -| sha | string | false | | Specify a different commit SHA used
for comparing changes | -| since | string | false | | Get changed files for commits whose
timestamp is older than the given
time. | -| since_last_remote_commit | string | true | `"false"` | Use the last commit on the
remote branch as the `base_sha`. Defaults
to the last non merge commit
on the target branch for pull
request events and the previous remote
commit of the current branch for
push events. | -| until | string | false | | Get changed files for commits whose
timestamp is earlier than the given
time. | -| write_output_files | string | false | `"false"` | Write outputs to files in the
`.github/outputs` folder by default. | +| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION | +|--------------------------------------------------------|--------|----------|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| base_sha | string | false | | Specify a different base commit SHA
used for comparing changes | +| diff_relative | string | false | | Exclude changes outside the current directory
and show path names relative to
it. **NOTE:** This requires you to
specify the top level directory via
the `path` input. | +| dir_names | string | false | `"false"` | Output unique changed directories instead of
filenames. **NOTE:** This returns `.` for
changed files located in the root
of the project. | +| dir_names_max_depth | string | false | | Maximum depth of directories to output.
e.g `test/test1/test2` with max depth of
`2` returns `test/test1`. | +| fetch_depth | string | false | `"50"` | Depth of additional branch history fetched.
**NOTE**: This can be adjusted to
resolve errors with insufficient history. | +| files | string | false | | File and directory patterns to detect
changes using only these list of
file(s) (Defaults to the entire repo) **NOTE:** Multiline file/directory patterns
should not include quotes. | +| files_from_source_file | string | false | | Source file(s) used to populate the
`files` input. | +| files_ignore | string | false | | Ignore changes to these file(s) **NOTE:**
Multiline file/directory patterns should not include
quotes. | +| files_ignore_from_source_file | string | false | | Source file(s) used to populate the
`files_ignore` input | +| files_ignore_separator | string | false | `"\n"` | Separator used to split the `files_ignore`
input | +| files_separator | string | false | `"\n"` | Separator used to split the `files`
input | +| include_all_old_new_renamed_files | string | false | `"false"` | Include `all_old_new_renamed_files` output. Note this can
generate a large output See: [#501](https://github.com/tj-actions/changed-files/issues/501). | +| json | string | false | `"false"` | Output list of changed files in
a JSON formatted string which can
be used for matrix jobs. | +| ~~json_raw_format~~
Use `json_unescaped` instead. | string | false | `"false"` | **Deprecated:** Output list of changed files
in a raw format which means
that the output will not be
surrounded by quotes and special characters
will not be escaped. | +| json_unescaped | string | false | `"false"` | Output list of changed files in
a JSON formatted string without escaping
special characters. | +| markdown_links | string | false | `"false"` | Boolean indicating whether to output input,
output and secret names as markdown
links | +| match_directories | string | false | `"true"` | Indicates whether to include match directories | +| old_new_files_separator | string | false | `" "` | Split character for old and new
renamed filename pairs. | +| old_new_separator | string | false | `","` | Split character for old and new
filename pairs. | +| output_dir | string | false | `".github/outputs"` | Directory to store output files. | +| path | string | false | `"."` | Specify a relative path under `$GITHUB_WORKSPACE`
to locate the repository. | +| quotepath | string | false | `"true"` | Use non ascii characters to match
files and output the filenames completely
verbatim by setting this to `false` | +| separator | string | false | `" "` | Split character for output strings. | +| sha | string | false | | Specify a different commit SHA used
for comparing changes | +| since | string | false | | Get changed files for commits whose
timestamp is older than the given
time. | +| since_last_remote_commit | string | true | `"false"` | Use the last commit on the
remote branch as the `base_sha`. Defaults
to the last non merge commit
on the target branch for pull
request events and the previous remote
commit of the current branch for
push events. | +| token | string | false | `"${{ github.token }}"` | The GitHub token to use for
authentication. | +| until | string | false | | Get changed files for commits whose
timestamp is earlier than the given
time. | +| write_output_files | string | false | `"false"` | Write outputs to files in the
`.github/outputs` folder by default. | diff --git a/test/action.yml b/test/action.yml index a8a3d993..47222443 100644 --- a/test/action.yml +++ b/test/action.yml @@ -112,6 +112,10 @@ inputs: description: "Boolean indicating whether to output input, output and secret names as markdown links" required: false default: "false" + token: + description: "The GitHub token to use for authentication." + required: false + default: ${{ github.token }} outputs: added_files: