Skip to content

Commit

Permalink
Enable customizing the commit message (#254)
Browse files Browse the repository at this point in the history
* customize commit message

* Update action.yml
  • Loading branch information
cicirello authored May 13, 2024
1 parent 83e42d5 commit 847964c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased] - 2024-03-07
## [Unreleased] - 2024-05-13

### Added
* An action input, `commit-message`, to enable customizing the commit message

### Changed

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,11 @@ that has configured required reviews or required checks:

The author of the commit is set to the github-actions bot.

### `commit-message`

The `commit-message` input enables customizing the commit message. The
default is `commit-message: 'Automated change by https://github.com/cicirello/user-statistician'`.
## Outputs
The action has only the following action output variable.
Expand Down Expand Up @@ -939,6 +944,7 @@ jobs:
locale: en
fail-on-error: true
commit-and-push: true
commit-message: 'Automated change by https://github.com/cicirello/user-statistician'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
9 changes: 7 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# user-statistician: Github action for generating a user stats card
#
# Copyright (c) 2021-2022 Vincent A Cicirello
# Copyright (c) 2021-2024 Vincent A Cicirello
# https://www.cicirello.org/
#
# MIT License
Expand Down Expand Up @@ -58,7 +58,7 @@ inputs:
required: false
default: true
locale:
description: 'ISO 639-1 two character language code'
description: 'One of the supported ISO 639-1 (two character) or ISO 639-2 (three character) language codes'
required: false
default: en
border-radius:
Expand Down Expand Up @@ -105,6 +105,10 @@ inputs:
description: 'Icon displayed at top of SVG to left and right of title'
required: false
default: default
commit-message:
description: 'The commit message'
required: false
default: 'Automated change by https://github.com/cicirello/user-statistician'
outputs:
exit-code:
description: '0 if successful or non-zero if unsuccessful'
Expand All @@ -131,3 +135,4 @@ runs:
- ${{ inputs.language-animation-speed }}
- ${{ inputs.image-width }}
- ${{ inputs.top-icon }}
- ${{ inputs.commit-message }}
13 changes: 9 additions & 4 deletions src/UserStatistician.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# user-statistician: Github action for generating a user stats card
#
# Copyright (c) 2021-2023 Vincent A Cicirello
# Copyright (c) 2021-2024 Vincent A Cicirello
# https://www.cicirello.org/
#
# MIT License
Expand Down Expand Up @@ -77,13 +77,15 @@ def executeCommand(arguments):
)
return result.stdout.strip(), result.returncode

def commitAndPush(filename, name, login, failOnError):
def commitAndPush(filename, name, login, failOnError, commit_message):
"""Commits and pushes the image.
Keyword arguments:
filename - The path to the image.
name - The user's name.
login - The user's login id.
failOnError - Boolean controlling whether or not to fail the run if an error occurs.
commit_message - Message for the commit
"""
# Resolve issue related to user in Docker container vs owner of repository
executeCommand(
Expand All @@ -104,7 +106,7 @@ def commitAndPush(filename, name, login, failOnError):
login + '@users.noreply.github.com'])
executeCommand(["git", "add", filename])
executeCommand(["git", "commit", "-m",
"Automated change by https://github.com/cicirello/user-statistician",
commit_message,
filename])
r = executeCommand(["git", "push"])
if r[1] != 0:
Expand Down Expand Up @@ -193,6 +195,8 @@ def commitAndPush(filename, name, login, failOnError):
colors.pop("title-icon", None)
elif topIcon != "default" and topIcon in iconTemplates:
colors["title-icon"] = topIcon

commit_message = sys.argv[20].strip()

stats = Statistician(
failOnError,
Expand Down Expand Up @@ -223,7 +227,8 @@ def commitAndPush(filename, name, login, failOnError):
imageFilenameWithPath,
"github-actions",
"41898282+github-actions[bot]",
failOnError)
failOnError,
commit_message)

set_outputs({"exit-code" : 0})

0 comments on commit 847964c

Please sign in to comment.