Skip to content

Commit cc635d1

Browse files
committed
fix(env): make git_branch fallback to github_ref
1 parent 2ce8e5a commit cc635d1

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

.env.defaults

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
GIT_BRANCH=master
21
GIT_HOST=github.com
32
GIT_COMMIT_MESSAGE=chore(actions): empty commit for contribution graph
43
GIT_SSH_COMMAND=ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no

.github/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Thanks for considering a contribution to this project! 🙏
3131
* Make sure to check the **Repo** boxes.
3232
* Note that the personal access token has more permissions than the `GITHUB_TOKEN` provided by the Actions runner. Read more about this [here](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token).
3333
* `GIT_EMAIL`: Set this to [an email associated with your GitHub account](https://github.com/settings/emails).
34+
* `GIT_BRANCH`: Set this to `master`.
3435
1. Make sure your Docker daemon is running.
3536

3637
### Running 👟

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
If you change your mind about these commits later, you can delete the repository and they'll disappear from your contribution graph.
4747

48-
### Push a commit to master once a day 🍺
48+
### Push a commit to GitHub once a day 🍺
4949

5050
```yml
5151
# .github/workflows/main.yml
@@ -66,16 +66,14 @@ jobs:
6666
6767
If you need help with cron job syntax, [crontab guru](https://crontab.guru/) is a great resource.
6868
69-
### Backfill a year of commits whenever you push to master 🍻
69+
### Backfill a year of commits whenever you push to GitHub 🍻
7070
7171
This rolls a pseudorandom number generator between 1 and 5 (inclusive) to determine how many commits to make per-day.
7272
7373
```yml
7474
# .github/workflows/main.yml
7575

76-
on:
77-
push:
78-
branches: [ master ]
76+
on: push
7977

8078
jobs:
8179
backfill-commits:
@@ -103,7 +101,7 @@ Keep reading for more cool stuff like:
103101
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|-----------|
104102
| `GITHUB_TOKEN` | Allows this GitHub Action to make commits for you. Simply pass in `${{ secrets.GITHUB_TOKEN }}`. [Read more](#github_token-). | | 🟩 |
105103
| `GIT_EMAIL` | An email address associated with your GitHub account. Without this, contributions won't show up. [Read more](#git_email-). | | 🟩 |
106-
| `GIT_BRANCH` | Must either be the default branch (usually `master`) or `gh-pages` for contributions to show up. | `master` | |
104+
| `GIT_BRANCH` | Must either be the default branch or `gh-pages` for contributions to show up. | The branch that triggered this Github Action | |
107105
| `GIT_COMMIT_MESSAGE` | The message to use for commits made by this GitHub Action. | `chore(actions): empty commit for contribution graph` | |
108106
| `ORIGIN_TIMESTAMP` | The unix timestamp to start commits on. If you set `MAX_DAYS` greater than 1, commits will be made on days prior to this time. | The current timestamp | |
109107
| `MAX_DAYS` | The maximum integer number of days to commit on. If you want to backfill a year of commits, set this to `365`. | `1` | |

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import git from 'simple-git/promise';
99
import {getRandomInt} from './random';
1010

1111
const env = autoParse({
12+
GIT_BRANCH: process.env.GIT_BRANCH || process.env.GITHUB_REF.replace(/^refs\/heads\//, ''),
1213
ORIGIN_TIMESTAMP: process.env.ORIGIN_TIMESTAMP || getUnixTime(new Date()),
1314
...dotenv.load({errorOnMissing: true, includeProcessEnv: true}),
1415
});

0 commit comments

Comments
 (0)