Skip to content

Commit

Permalink
feat: add custom commit message (#1136)
Browse files Browse the repository at this point in the history
* feat: add custom commit message

Addresses: #1135

* Update publish-gh-pages.js

* add support to v2 as well

* docs: add them

* docs
  • Loading branch information
jakebolam authored and endiliey committed Dec 4, 2018
1 parent cb1395e commit c4a9b31
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
11 changes: 10 additions & 1 deletion docs/getting-started-publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,17 @@ Now, whenever a new commit lands in `master`, CircleCI will run your suite of te
### Tips & Tricks

When initially deploying to a `gh-pages` branch using Circle CI, you may notice that some jobs triggered by commits to the `gh-pages` branch fail to run successfully due to a lack of tests. You can easily work around this by creating a basic Circle CI config with the following contents:
When initially deploying to a `gh-pages` branch using Circle CI, you may notice that some jobs triggered by commits to the `gh-pages` branch fail to run successfully due to a lack of tests (This can also result in chat/slack build failure notifications).

You can work around this easily by:
- Setting the environment variable `CUSTOM_COMMIT_MESSAGE` flag to the `publish-gh-pages` command with the contents of `[skip ci]`.
e.g.
```bash
CUSTOM_COMMIT_MESSAGE="[skip ci]" \
yarn run publish-gh-pages # or `npm run publish-gh-pages`
```

- Alternatively you can work around this by creating a basic Circle CI config with the following contents:
```yaml
# Circle CI 2.0 Config File
# This config file will prevent tests from being run on the gh-pages branch.
Expand Down
4 changes: 3 additions & 1 deletion v1/lib/publish-gh-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const GITHUB_DOMAIN = 'github.com';
// For GitHub enterprise, allow specifying a different host.
const GITHUB_HOST =
process.env.GITHUB_HOST || siteConfig.githubHost || GITHUB_DOMAIN;
const CUSTOM_COMMIT_MESSAGE = process.env.CUSTOM_COMMIT_MESSAGE;

if (!ORGANIZATION_NAME) {
shell.echo(
Expand Down Expand Up @@ -166,8 +167,9 @@ fs.copy(
shell.cd(path.join('build', `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`));
shell.exec('git add --all');

const commitMessage = CUSTOM_COMMIT_MESSAGE || 'Deploy website';
const commitResults = shell.exec(
`git commit -m "Deploy website" -m "Deploy website version based on ${currentCommit}"`,
`git commit -m "${commitMessage}" -m "Deploy website version based on ${currentCommit}"`,
);
if (shell.exec(`git push origin ${DEPLOYMENT_BRANCH}`).code !== 0) {
shell.echo('Error: Git push failed');
Expand Down
4 changes: 3 additions & 1 deletion v2/lib/commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ module.exports = async function deploy(siteDir) {
shell.cd(path.join('build', `${projectName}-${deploymentBranch}`));
shell.exec('git add --all');

const commitMessage =
process.env.CUSTOM_COMMIT_MESSAGE || 'Deploy website';
const commitResults = shell.exec(
`git commit -m "Deploy website" -m "Deploy website version based on ${currentCommit}"`,
`git commit -m "${commitMessage}" -m "Deploy website version based on ${currentCommit}"`,
);
if (shell.exec(`git push origin ${deploymentBranch}`).code !== 0) {
throw new Error('Error: Git push failed');
Expand Down

0 comments on commit c4a9b31

Please sign in to comment.