This action creates a commit using the workflow's $GITHUB_TOKEN
, pushes it to the
specified branch, and optionally creates a tag pointing to the newly created commit.
permissions:
# contents:write permission is required to make the commits/tags
contents: write
steps:
- name: Modify and delete some files
run: |
echo "I've added a line to this file" >> README.md
rm ./some-file-I-dont-need.txt
- name: Commit and push changes
uses: saasquatch/git-commit-action@v0.0.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
README.md
some-file-I-dont-need.txt
message: "ci: modify and delete some files"
long-message: This commit was generated by GitHub Actions CI
tag: v1.0.0
tag-message: This is a tag for the commit I just made
repository: ${{ github.repository }}
branch: ${{ github.ref_name }}
The reason why this action is necessary is because creating commits in CI on the command
line with the git
program results in un-verified commits, even if you specify the
GitHub actions email and everything. In repositories that require verified commits this
is a problem. Creating the commits using the GitHub REST API and authorizing with the
$GITHUB_TOKEN
results in signed commits which pass the repository rulesets.