Skip to content

Commit

Permalink
Added configurations for PR and commit message (#5)
Browse files Browse the repository at this point in the history
* Updated the action.yml with the default messages

* Updated the script to use the user configured messages

* Updated the documentation

* Fixed the documentation
  • Loading branch information
Thejus-Paul authored Feb 27, 2023
1 parent 2537d95 commit 2d83104
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 10 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ The GitHub action to bump the gem or engine version from the pull request labels

**Required** The GitHub token to authenticate with GitHub API.

## `branch`

**Optional** The branch to push the changes to. Default `"bump-gem-version"`.

## `commit_message`

**Optional** The commit message to use. Default `"Updated gem version"`.

## `pr_title`

**Optional** The pull request title to use. Default `"Updated gem version"`.

## `pr_body`

**Optional** The pull request body to use. Default `"New version release"`.

## Example usage

```yaml
Expand Down
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ inputs:
description: 'Provide a branch name to be used for the PR.'
required: false
default: 'bump-gem-version'
commit_message:
description: 'Provide a commit message for the gem version bump.'
required: false
default: 'Updated gem version'
pr_title:
description: 'Provide a title for the PR.'
required: false
default: 'Updated gem version'
pr_body:
description: 'Provide a body for the PR.'
required: false
default: 'New version release'
runs:
using: 'node16'
main: 'dist/index.js'
Expand Down
15 changes: 10 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11143,6 +11143,8 @@ const getChangedFiles = async (changedFiles) => {
};

const createCommit = async (octokit, context, branchName) => {
const commitMessage = core.getInput("commit_message");

try {
const branch = await octokit.rest.repos.getBranch({
...context.repo,
Expand Down Expand Up @@ -11179,7 +11181,7 @@ const createCommit = async (octokit, context, branchName) => {
...context.repo,
tree: commitableFiles,
base_tree: commitSHA,
message: "Bumped gem version",
message: commitMessage,
parents: [commitSHA],
});

Expand All @@ -11188,7 +11190,7 @@ const createCommit = async (octokit, context, branchName) => {
} = await octokit.rest.git.createCommit({
...context.repo,
tree: currentTreeSHA,
message: "Bumped gem version",
message: commitMessage,
parents: [commitSHA],
});

Expand All @@ -11205,12 +11207,15 @@ const createCommit = async (octokit, context, branchName) => {
};

const createPR = async (octokit, context, branchName) => {
const title = core.getInput("pr_title");
const body = core.getInput("pr_body");

try {
const response = await octokit.rest.pulls.create({
head: branchName,
base: "main",
title: "Bump gem version",
body: "Bump gem version",
body,
head: branchName,
title,
...context.repo,
});
return response?.data?.number;
Expand Down
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ const getChangedFiles = async (changedFiles) => {
};

const createCommit = async (octokit, context, branchName) => {
const commitMessage = core.getInput("commit_message");

try {
const branch = await octokit.rest.repos.getBranch({
...context.repo,
Expand Down Expand Up @@ -112,7 +114,7 @@ const createCommit = async (octokit, context, branchName) => {
...context.repo,
tree: commitableFiles,
base_tree: commitSHA,
message: "Bumped gem version",
message: commitMessage,
parents: [commitSHA],
});

Expand All @@ -121,7 +123,7 @@ const createCommit = async (octokit, context, branchName) => {
} = await octokit.rest.git.createCommit({
...context.repo,
tree: currentTreeSHA,
message: "Bumped gem version",
message: commitMessage,
parents: [commitSHA],
});

Expand All @@ -138,12 +140,15 @@ const createCommit = async (octokit, context, branchName) => {
};

const createPR = async (octokit, context, branchName) => {
const title = core.getInput("pr_title");
const body = core.getInput("pr_body");

try {
const response = await octokit.rest.pulls.create({
head: branchName,
base: "main",
title: "Bump gem version",
body: "Bump gem version",
body,
head: branchName,
title,
...context.repo,
});
return response?.data?.number;
Expand Down

0 comments on commit 2d83104

Please sign in to comment.