From 9e859999aa8df6be60e731407f7726d752f85e3a Mon Sep 17 00:00:00 2001 From: orhun Date: Fri, 18 Jun 2021 03:00:25 +0300 Subject: [PATCH] feat(input): use the config file from given path --- .github/workflows/main.yml | 1 + README.md | 4 +++- action.yml | 8 ++++++-- fixtures/cliff.toml | 25 +++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 fixtures/cliff.toml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6668adc..3b43532 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,6 +11,7 @@ jobs: id: git-cliff uses: ./ with: + config: fixtures/cliff.toml args: --verbose - name: Print the changelog run: echo "${{ steps.git-cliff.outputs.changelog }}" diff --git a/README.md b/README.md index 041bc93..19ca2d5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ This action generates a changelog based on your Git history using [git-cliff](ht ### Inputs -* `args`: Arguments to pass to git-cliff. Default `"-v"` +* `config`: Path of the configuration file. Default: `"cliff.toml"` +* `args`: Arguments to pass to git-cliff. Default: `"-v"` ### Outputs @@ -18,6 +19,7 @@ This action generates a changelog based on your Git history using [git-cliff](ht - name: Changelog Generator uses: orhun/git-cliff-action@v1 with: + config: cliff.toml args: --verbose ``` diff --git a/action.yml b/action.yml index 9c6b110..b905b2f 100644 --- a/action.yml +++ b/action.yml @@ -1,18 +1,22 @@ name: "git-cliff: Changelog Generator" description: "Generate changelog based on your Git history" inputs: + config: + description: "config file location" + required: false + default: "cliff.toml" args: description: "git-cliff arguments" required: false default: "-v" outputs: changelog: - description: 'generated changelog' + description: "generated changelog" runs: using: "docker" image: "Dockerfile" args: - - ${{ inputs.args }} + - "-c ${{ inputs.config }} ${{ inputs.args }}" branding: icon: "triangle" color: "orange" diff --git a/fixtures/cliff.toml b/fixtures/cliff.toml new file mode 100644 index 0000000..7a592f4 --- /dev/null +++ b/fixtures/cliff.toml @@ -0,0 +1,25 @@ +# configuration file for git-cliff (0.1.0) + +[changelog] +header = "# Changelog\n" +body = """ +{% if version %}\ + ## [{{ version | replace(from="v", to="") }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | upper_first }} + {% for group, commits in commits | group_by(attribute="scope") %}\ + #### {{ group }}\ + {% for commit in commits %} + - {{ commit.message | upper_first }}\ + {% endfor %} + {% endfor %}\ +{% endfor %}\n +""" +trim=true +footer = "\n" + +[git] +conventional_commits = true