mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +02:00
feat: add custom commit message (#1136)
* feat: add custom commit message Addresses: #1135 * Update publish-gh-pages.js * add support to v2 as well * docs: add them * docs
This commit is contained in:
parent
cb1395ee29
commit
c4a9b31984
3 changed files with 16 additions and 3 deletions
|
@ -162,8 +162,17 @@ Now, whenever a new commit lands in `master`, CircleCI will run your suite of te
|
||||||
|
|
||||||
### Tips & Tricks
|
### 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
|
```yaml
|
||||||
# Circle CI 2.0 Config File
|
# Circle CI 2.0 Config File
|
||||||
# This config file will prevent tests from being run on the gh-pages branch.
|
# This config file will prevent tests from being run on the gh-pages branch.
|
||||||
|
|
|
@ -39,6 +39,7 @@ const GITHUB_DOMAIN = 'github.com';
|
||||||
// For GitHub enterprise, allow specifying a different host.
|
// For GitHub enterprise, allow specifying a different host.
|
||||||
const GITHUB_HOST =
|
const GITHUB_HOST =
|
||||||
process.env.GITHUB_HOST || siteConfig.githubHost || GITHUB_DOMAIN;
|
process.env.GITHUB_HOST || siteConfig.githubHost || GITHUB_DOMAIN;
|
||||||
|
const CUSTOM_COMMIT_MESSAGE = process.env.CUSTOM_COMMIT_MESSAGE;
|
||||||
|
|
||||||
if (!ORGANIZATION_NAME) {
|
if (!ORGANIZATION_NAME) {
|
||||||
shell.echo(
|
shell.echo(
|
||||||
|
@ -166,8 +167,9 @@ fs.copy(
|
||||||
shell.cd(path.join('build', `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`));
|
shell.cd(path.join('build', `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`));
|
||||||
shell.exec('git add --all');
|
shell.exec('git add --all');
|
||||||
|
|
||||||
|
const commitMessage = CUSTOM_COMMIT_MESSAGE || 'Deploy website';
|
||||||
const commitResults = shell.exec(
|
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) {
|
if (shell.exec(`git push origin ${DEPLOYMENT_BRANCH}`).code !== 0) {
|
||||||
shell.echo('Error: Git push failed');
|
shell.echo('Error: Git push failed');
|
||||||
|
|
|
@ -158,8 +158,10 @@ module.exports = async function deploy(siteDir) {
|
||||||
shell.cd(path.join('build', `${projectName}-${deploymentBranch}`));
|
shell.cd(path.join('build', `${projectName}-${deploymentBranch}`));
|
||||||
shell.exec('git add --all');
|
shell.exec('git add --all');
|
||||||
|
|
||||||
|
const commitMessage =
|
||||||
|
process.env.CUSTOM_COMMIT_MESSAGE || 'Deploy website';
|
||||||
const commitResults = shell.exec(
|
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) {
|
if (shell.exec(`git push origin ${deploymentBranch}`).code !== 0) {
|
||||||
throw new Error('Error: Git push failed');
|
throw new Error('Error: Git push failed');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue