Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add custom commit message #1136

Merged
merged 5 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the chat/slack build notifications to pickup on commonly searched google terms


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