fix(env): make git_branch fallback to github_ref

This commit is contained in:
Borja Canseco
2020-10-09 23:07:37 -05:00
parent 2ce8e5ab70
commit cc635d1b7e
4 changed files with 6 additions and 7 deletions

View File

@@ -1,4 +1,3 @@
GIT_BRANCH=master
GIT_HOST=github.com
GIT_COMMIT_MESSAGE=chore(actions): empty commit for contribution graph
GIT_SSH_COMMAND=ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no

View File

@@ -31,6 +31,7 @@ Thanks for considering a contribution to this project! 🙏
* Make sure to check the **Repo** boxes.
* 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).
* `GIT_EMAIL`: Set this to [an email associated with your GitHub account](https://github.com/settings/emails).
* `GIT_BRANCH`: Set this to `master`.
1. Make sure your Docker daemon is running.
### Running 👟

View File

@@ -45,7 +45,7 @@
If you change your mind about these commits later, you can delete the repository and they'll disappear from your contribution graph.
### Push a commit to master once a day 🍺
### Push a commit to GitHub once a day 🍺
```yml
# .github/workflows/main.yml
@@ -66,16 +66,14 @@ jobs:
If you need help with cron job syntax, [crontab guru](https://crontab.guru/) is a great resource.
### Backfill a year of commits whenever you push to master 🍻
### Backfill a year of commits whenever you push to GitHub 🍻
This rolls a pseudorandom number generator between 1 and 5 (inclusive) to determine how many commits to make per-day.
```yml
# .github/workflows/main.yml
on:
push:
branches: [ master ]
on: push
jobs:
backfill-commits:
@@ -103,7 +101,7 @@ Keep reading for more cool stuff like:
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|-----------|
| `GITHUB_TOKEN` | Allows this GitHub Action to make commits for you. Simply pass in `${{ secrets.GITHUB_TOKEN }}`. [Read more](#github_token-). | | 🟩 |
| `GIT_EMAIL` | An email address associated with your GitHub account. Without this, contributions won't show up. [Read more](#git_email-). | | 🟩 |
| `GIT_BRANCH` | Must either be the default branch (usually `master`) or `gh-pages` for contributions to show up. | `master` | |
| `GIT_BRANCH` | Must either be the default branch or `gh-pages` for contributions to show up. | The branch that triggered this Github Action | |
| `GIT_COMMIT_MESSAGE` | The message to use for commits made by this GitHub Action. | `chore(actions): empty commit for contribution graph` | |
| `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 | |
| `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` | |

View File

@@ -9,6 +9,7 @@ import git from 'simple-git/promise';
import {getRandomInt} from './random';
const env = autoParse({
GIT_BRANCH: process.env.GIT_BRANCH || process.env.GITHUB_REF.replace(/^refs\/heads\//, ''),
ORIGIN_TIMESTAMP: process.env.ORIGIN_TIMESTAMP || getUnixTime(new Date()),
...dotenv.load({errorOnMissing: true, includeProcessEnv: true}),
});