mirror of
https://github.com/bcanseco/github-contribution-graph-action.git
synced 2025-10-09 13:41:58 +03:00
feat: initial commit
This commit is contained in:
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.git
|
||||
clone
|
||||
node_modules
|
||||
5
.env.example
Normal file
5
.env.example
Normal file
@@ -0,0 +1,5 @@
|
||||
GITHUB_ACTOR=
|
||||
GITHUB_REPOSITORY=
|
||||
|
||||
GITHUB_TOKEN=
|
||||
GIT_EMAIL=
|
||||
199
.gitattributes
vendored
Normal file
199
.gitattributes
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
## GITATTRIBUTES FOR WEB PROJECTS
|
||||
#
|
||||
# These settings are for any web project.
|
||||
#
|
||||
# Details per file setting:
|
||||
# text These files should be normalized (i.e. convert CRLF to LF).
|
||||
# binary These files are binary and should be left untouched.
|
||||
#
|
||||
# Note that binary is a macro for -text -diff.
|
||||
######################################################################
|
||||
|
||||
# Auto detect
|
||||
## Handle line endings automatically for files detected as
|
||||
## text and leave all files detected as binary untouched.
|
||||
## This will handle all files NOT defined below.
|
||||
* text=auto
|
||||
|
||||
# Source code
|
||||
*.bash text eol=lf
|
||||
*.bat text eol=crlf
|
||||
*.cmd text eol=crlf
|
||||
*.coffee text
|
||||
*.css text
|
||||
*.htm text diff=html
|
||||
*.html text diff=html
|
||||
*.inc text
|
||||
*.ini text
|
||||
*.js text
|
||||
*.json text
|
||||
*.jsx text
|
||||
*.less text
|
||||
*.ls text
|
||||
*.map text -diff
|
||||
*.od text
|
||||
*.onlydata text
|
||||
*.php text diff=php
|
||||
*.pl text
|
||||
*.ps1 text eol=crlf
|
||||
*.py text diff=python
|
||||
*.rb text diff=ruby
|
||||
*.sass text
|
||||
*.scm text
|
||||
*.scss text diff=css
|
||||
*.sh text eol=lf
|
||||
*.sql text
|
||||
*.styl text
|
||||
*.tag text
|
||||
*.ts text
|
||||
*.tsx text
|
||||
*.xml text
|
||||
*.xhtml text diff=html
|
||||
|
||||
# Docker
|
||||
Dockerfile text
|
||||
|
||||
# Documentation
|
||||
*.ipynb text
|
||||
*.markdown text
|
||||
*.md text
|
||||
*.mdwn text
|
||||
*.mdown text
|
||||
*.mkd text
|
||||
*.mkdn text
|
||||
*.mdtxt text
|
||||
*.mdtext text
|
||||
*.txt text
|
||||
AUTHORS text
|
||||
CHANGELOG text
|
||||
CHANGES text
|
||||
CONTRIBUTING text
|
||||
COPYING text
|
||||
copyright text
|
||||
*COPYRIGHT* text
|
||||
INSTALL text
|
||||
license text
|
||||
LICENSE text
|
||||
NEWS text
|
||||
readme text
|
||||
*README* text
|
||||
TODO text
|
||||
|
||||
# Templates
|
||||
*.dot text
|
||||
*.ejs text
|
||||
*.haml text
|
||||
*.handlebars text
|
||||
*.hbs text
|
||||
*.hbt text
|
||||
*.jade text
|
||||
*.latte text
|
||||
*.mustache text
|
||||
*.njk text
|
||||
*.phtml text
|
||||
*.tmpl text
|
||||
*.tpl text
|
||||
*.twig text
|
||||
*.vue text
|
||||
|
||||
# Configs
|
||||
*.cnf text
|
||||
*.conf text
|
||||
*.config text
|
||||
.editorconfig text
|
||||
.env text
|
||||
.gitattributes text
|
||||
.gitconfig text
|
||||
.htaccess text
|
||||
*.lock text -diff
|
||||
package-lock.json text -diff
|
||||
*.toml text
|
||||
*.yaml text
|
||||
*.yml text
|
||||
browserslist text
|
||||
Makefile text
|
||||
makefile text
|
||||
|
||||
# Heroku
|
||||
Procfile text
|
||||
|
||||
# Graphics
|
||||
*.ai binary
|
||||
*.bmp binary
|
||||
*.eps binary
|
||||
*.gif binary
|
||||
*.gifv binary
|
||||
*.ico binary
|
||||
*.jng binary
|
||||
*.jp2 binary
|
||||
*.jpg binary
|
||||
*.jpeg binary
|
||||
*.jpx binary
|
||||
*.jxr binary
|
||||
*.pdf binary
|
||||
*.png binary
|
||||
*.psb binary
|
||||
*.psd binary
|
||||
# SVG treated as an asset (binary) by default.
|
||||
*.svg text
|
||||
# If you want to treat it as binary,
|
||||
# use the following line instead.
|
||||
# *.svg binary
|
||||
*.svgz binary
|
||||
*.tif binary
|
||||
*.tiff binary
|
||||
*.wbmp binary
|
||||
*.webp binary
|
||||
|
||||
# Audio
|
||||
*.kar binary
|
||||
*.m4a binary
|
||||
*.mid binary
|
||||
*.midi binary
|
||||
*.mp3 binary
|
||||
*.ogg binary
|
||||
*.ra binary
|
||||
|
||||
# Video
|
||||
*.3gpp binary
|
||||
*.3gp binary
|
||||
*.as binary
|
||||
*.asf binary
|
||||
*.asx binary
|
||||
*.fla binary
|
||||
*.flv binary
|
||||
*.m4v binary
|
||||
*.mng binary
|
||||
*.mov binary
|
||||
*.mp4 binary
|
||||
*.mpeg binary
|
||||
*.mpg binary
|
||||
*.ogv binary
|
||||
*.swc binary
|
||||
*.swf binary
|
||||
*.webm binary
|
||||
|
||||
# Archives
|
||||
*.7z binary
|
||||
*.gz binary
|
||||
*.jar binary
|
||||
*.rar binary
|
||||
*.tar binary
|
||||
*.zip binary
|
||||
|
||||
# Fonts
|
||||
*.ttf binary
|
||||
*.eot binary
|
||||
*.otf binary
|
||||
*.woff binary
|
||||
*.woff2 binary
|
||||
|
||||
# Executables
|
||||
*.exe binary
|
||||
*.pyc binary
|
||||
|
||||
# RC files (like .babelrc or .eslintrc)
|
||||
*.*rc text
|
||||
|
||||
# Ignore files (like .npmignore or .gitignore)
|
||||
*.*ignore text
|
||||
76
.github/CODE_OF_CONDUCT.md
vendored
Normal file
76
.github/CODE_OF_CONDUCT.md
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project lead at [borj@cans.eco](mailto:borj@cans.eco). All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
67
.github/CONTRIBUTING.md
vendored
Normal file
67
.github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
# Contributing guide
|
||||
|
||||
Thanks for considering a contribution to this project! 🙏
|
||||
|
||||
## Local development with Docker 🐳
|
||||
|
||||
### Requirements 📝
|
||||
|
||||
* [git](https://git-scm.com)
|
||||
* [Docker](https://docs.docker.com/get-docker/)
|
||||
|
||||
### Setup 🛠
|
||||
|
||||
1. Clone and navigate to the repo:
|
||||
```console
|
||||
$ git clone https://github.com/bcanseco/github-contribution-graph-action.git
|
||||
$ cd github-contribution-graph-action
|
||||
```
|
||||
1. Create an `.env` file:
|
||||
```console
|
||||
$ cp .env.example .env
|
||||
```
|
||||
1. Fill in the values.
|
||||
* `GITHUB_ACTOR`: Set this to your GitHub username.
|
||||
* e.g. `bcanseco`
|
||||
* Note that when running as a GitHub Action, the user doesn't need to provide this.
|
||||
* `GITHUB_REPOSITORY`: Set this to your username followed by a slash and your repository name.
|
||||
* e.g. `bcanseco/github-contribution-graph-action`
|
||||
* Again, this is only necessary when running locally.
|
||||
* `GITHUB_TOKEN`: Set this to [your personal access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line).
|
||||
* 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).
|
||||
1. Make sure your Docker daemon is running.
|
||||
|
||||
### Running 👟
|
||||
|
||||
Use the commands below to build and run a container:
|
||||
|
||||
```console
|
||||
$ docker build -t github-contribution-graph-action .
|
||||
$ docker run -w /app --rm github-contribution-graph-action
|
||||
```
|
||||
|
||||
You can alternatively run `npm start` directly without Docker, but this isn't recommended.
|
||||
|
||||
## Q&A 🤔
|
||||
|
||||
### Why is this a Docker action and not a JavaScript action? 📦
|
||||
|
||||
Two reasons:
|
||||
|
||||
1. For things like this that mess with the `git` CLI directly, it's easier to test with containers.
|
||||
1. You cannot currently specify an [npm run-script](https://docs.npmjs.com/cli/run-script) (e.g. `npm start`) as an entrypoint with JavaScript actions.
|
||||
|
||||
### Why go with Unix rather than ISO for `ORIGIN_TIMESTAMP`? ⌚
|
||||
|
||||
For some reason, the GitHub Actions runner mutates ISO timestamp strings passed as environment variables into something unparseable by the `date-fns` library.
|
||||
|
||||
### Why use environment variables instead of [inputs][inputs]? 🔌
|
||||
|
||||
[inputs]: https://help.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs
|
||||
|
||||
Two reasons:
|
||||
|
||||
1. GitHub transforms input parameter casing and prepends `INPUT_`, so additional code would be necessary to revert this before processing them.
|
||||
1. Input parameters are expected to be documented in the [action definition](../action.yml), which would be yet another source of truth to maintain.
|
||||
9
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
9
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help me improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
9
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
9
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
12
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
12
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
**Brief overview:** <!-- Write a summary of what this PR does below. Screenshots are cool! -->
|
||||
|
||||
|
||||
**Changelog:**
|
||||
* <!-- Completed item 1 -->
|
||||
* <!-- Completed item 2 -->
|
||||
* <!-- etc. -->
|
||||
|
||||
**Steps to test/confirm my changes:**
|
||||
1. <!-- Step 1 -->
|
||||
2. <!-- Step 2 -->
|
||||
3. <!-- etc. -->
|
||||
5
.github/SECURITY.md
vendored
Normal file
5
.github/SECURITY.md
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# Security Policy
|
||||
|
||||
Please email [borj@cans.eco](mailto:borj@cans.eco) if you find a security vulnerability on this project. If you find a *potential* vulnerability, feel free to leave an issue and I'll respond ASAP.
|
||||
|
||||
Thanks for disclosing responsibly 🖤
|
||||
BIN
.github/images/cover.png
vendored
Normal file
BIN
.github/images/cover.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 706 KiB |
BIN
.github/images/create-new-file.png
vendored
Normal file
BIN
.github/images/create-new-file.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
BIN
.github/images/name-new-file.png
vendored
Normal file
BIN
.github/images/name-new-file.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
16
.github/workflows/audit.yml
vendored
Normal file
16
.github/workflows/audit.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: audit
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '0 12 * * *' # every day at noon
|
||||
|
||||
jobs:
|
||||
audit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- run: npm audit --production
|
||||
29
.github/workflows/build.yml
vendored
Normal file
29
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
commitizen:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: outillage/commitsar@master
|
||||
markdown:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: gaurav-nelson/github-action-markdown-link-check@master
|
||||
dogfooding:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master # only required for eating our own dog food
|
||||
- uses: ./
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GIT_EMAIL: borj@cans.eco
|
||||
GIT_BRANCH: gh-pages
|
||||
GIT_COMMIT_MESSAGE: 'chore(actions): dogfooding triggered by push'
|
||||
118
.gitignore
vendored
Normal file
118
.gitignore
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
clone
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
||||
# This version of Node.js or later is required for top-level await.
|
||||
FROM node:14.3.0
|
||||
|
||||
# When running as a GitHub Action, the WORKDIR is controlled by GitHub.
|
||||
# Furthermore, they recommend NOT setting it in the Dockerfile, which makes running locally difficult.
|
||||
# Thus we copy files to an /app directory to be used when running Docker outside GitHub Actions.
|
||||
COPY . /app
|
||||
|
||||
# Executing a shell is required for environment variable substitution when running as a GitHub Action.
|
||||
ENTRYPOINT ["sh", "-c", "npm install --production && npm start"]
|
||||
19
LICENSE
Normal file
19
LICENSE
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2020 Borja Canseco
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
157
README.md
Normal file
157
README.md
Normal file
@@ -0,0 +1,157 @@
|
||||
<p align="center">
|
||||
<img width="150px" src="./.github/images/cover.png">
|
||||
</p>
|
||||
|
||||
<h1 align="center">
|
||||
Contribution Graph Action
|
||||
</h1>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/bcanseco/github-contribution-graph-action/actions?query=workflow%3Abuild">
|
||||
<img src="https://github.com/bcanseco/github-contribution-graph-action/workflows/build/badge.svg">
|
||||
</a>
|
||||
|
||||
<a href="https://github.com/bcanseco/github-contribution-graph-action/actions?query=workflow%3Aaudit">
|
||||
<img src="https://github.com/bcanseco/github-contribution-graph-action/workflows/audit/badge.svg">
|
||||
</a>
|
||||
|
||||
<a href="https://github.com/marketplace/actions/contribution-graph">
|
||||
<img src="https://img.shields.io/badge/action-marketplace-orange?logo=github">
|
||||
</a>
|
||||
|
||||
<a href="https://github.com/bcanseco/github-contribution-graph-action/releases">
|
||||
<img src="https://img.shields.io/github/v/release/bcanseco/github-contribution-graph-action.svg?logo=github">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## Quick start without leaving your browser ⚡
|
||||
|
||||
1. [Create a new repo](https://github.com/new) (preferably private)
|
||||
1. Click on **Create a new file**
|
||||

|
||||
1. In the **Name your file...** field, type in `.github/workflows/main.yml`
|
||||

|
||||
1. Paste in one of the YAML file contents below, depending on what you want to do.
|
||||
1. Click the **Commit new file** button at the bottom of the page. You're all set!
|
||||
|
||||
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 🍺
|
||||
|
||||
```yml
|
||||
# .github/workflows/main.yml
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 12 * * *' # every day at noon
|
||||
|
||||
jobs:
|
||||
single-commit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: bcanseco/github-contribution-graph-action@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GIT_EMAIL: you@youremail.com # replace me
|
||||
```
|
||||
|
||||
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 🍻
|
||||
|
||||
```yml
|
||||
# .github/workflows/main.yml
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
backfill-commits:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: bcanseco/github-contribution-graph-action@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GIT_EMAIL: you@youremail.com # replace me
|
||||
MAX_DAYS: 365
|
||||
```
|
||||
|
||||
Keep reading for more cool stuff like:
|
||||
|
||||
* skipping weekends/weekdays
|
||||
* backfilling specific time periods
|
||||
* custom commit messages
|
||||
* and more!
|
||||
|
||||
## Environment variables 🌳
|
||||
|
||||
| Key | Description | Default value | Required? |
|
||||
|----------------------|-------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|-----------|
|
||||
| `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_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` | |
|
||||
| `INCLUDE_WEEKDAYS` | A boolean indicating whether or not to make commits on weekdays. | `true` | |
|
||||
| `INCLUDE_WEEKENDS` | A boolean indicating whether or not to make commits on weekends. | `true` | |
|
||||
|
||||
### Advanced environment variables 🧙♂️
|
||||
|
||||
<details>
|
||||
|
||||
<summary>There's also some advanced environment variables you can provide. Click here!</summary>
|
||||
|
||||
Only set these if you know what you're doing:
|
||||
|
||||
| Key | Description | Default value | Required? |
|
||||
|---------------------|------------------------------------------------------------------------------|-------------------------------------------------------------------|-----------|
|
||||
| `GIT_HOST` | You may be able to override this to support a GitHub Enterprise environment. | `github.com` | |
|
||||
| `GIT_SSH_COMMAND` | | `ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no` | |
|
||||
| `GITHUB_ACTOR` | | Set by the GitHub Actions runner | |
|
||||
| `GITHUB_REPOSITORY` | | Set by the GitHub Actions runner | |
|
||||
|
||||
</details>
|
||||
|
||||
## How do I know this is secure? 🔒
|
||||
|
||||
Explore the [code](src/index.js)! It's tiny and there aren't many dependencies.
|
||||
|
||||
Speaking of dependencies, all production npm dependencies used by this GitHub Action are [automatically audited](./.github/workflows/audit.yml) for vulnerabilities. If the badge at the top of this README is green, you're good to go.
|
||||
|
||||
If you're still worried about malicious code in this repository, GitHub recommends always using a specific version of any GitHub Actions you add to your repositories. [Read more](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsuses).
|
||||
|
||||
```diff
|
||||
- uses: bcanseco/github-contribution-graph-action@master
|
||||
+ uses: bcanseco/github-contribution-graph-action@v1
|
||||
```
|
||||
|
||||
As far as data security, there's two sensitive pieces of data that this Action handles:
|
||||
|
||||
* [`GITHUB_TOKEN`](#github_token-)
|
||||
* [`GIT_EMAIL`](#git_email-)
|
||||
|
||||
### `GITHUB_TOKEN` 🔑
|
||||
|
||||
GitHub has [a great article](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#using-the-github_token-in-a-workflow) about the token. It's the standard way that all GitHub Actions interact with GitHub on your behalf. The permissions of this token are both short-lived scoped to the repo only.
|
||||
|
||||
You don't need to create this secret yourself; GitHub handles that for you. All you need to do is provide the token in your workflow, job, or step:
|
||||
|
||||
```yml
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### `GIT_EMAIL` 📧
|
||||
|
||||
This GitHub Action requires an email associated with your GitHub account. If you provide a random or throwaway email, contributions won't show up on your GitHub profile. [Read more](https://help.github.com/en/github/setting-up-and-managing-your-github-profile/why-are-my-contributions-not-showing-up-on-my-profile#you-havent-added-your-local-git-commit-email-to-your-profile).
|
||||
|
||||
Chances are, your email is already public if you're making commits with it. But if you're concerned about privacy, you can do either of the following:
|
||||
|
||||
* [Add your email as a secret](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets-for-a-repository) and pass it in the same way as the `GITHUB_TOKEN`
|
||||
* [Use your GitHub-provided `noreply` email address](https://help.github.com/en/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address#about-commit-email-addresses)
|
||||
|
||||
## Contribute 👪
|
||||
|
||||
PRs are welcome! Please read the [contributing guide](.github/CONTRIBUTING.md). This project is [MIT](LICENSE) licensed.
|
||||
9
action.yml
Normal file
9
action.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
name: 'Autopopulate your contribution graph'
|
||||
author: 'Borja Canseco <borj@cans.eco>'
|
||||
description: 'This action will automatically push empty commits to one of your GitHub repos.'
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
branding:
|
||||
icon: 'grid'
|
||||
color: 'green'
|
||||
51
package-lock.json
generated
Normal file
51
package-lock.json
generated
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"@kwsites/exec-p": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@kwsites/exec-p/-/exec-p-0.4.0.tgz",
|
||||
"integrity": "sha512-44DWNv5gDR9EwrCTVQ4ZC99yPqVS0VCWrYIBl45qNR8XQy+4lbl0IQG8kBDf6NHwj4Ib4c2z1Fq1IUJOCbkZcw=="
|
||||
},
|
||||
"date-fns": {
|
||||
"version": "2.14.0",
|
||||
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.14.0.tgz",
|
||||
"integrity": "sha512-1zD+68jhFgDIM0rF05rcwYO8cExdNqxjq4xP1QKM60Q45mnO6zaMWB4tOzrIr4M4GSLntsKeE4c9Bdl2jhL/yw=="
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"dotenv": {
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
|
||||
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
|
||||
},
|
||||
"dotenv-safe": {
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dotenv-safe/-/dotenv-safe-8.2.0.tgz",
|
||||
"integrity": "sha512-uWwWWdUQkSs5a3mySDB22UtNwyEYi0JtEQu+vDzIqr9OjbDdC2Ip13PnSpi/fctqlYmzkxCeabiyCAOROuAIaA==",
|
||||
"requires": {
|
||||
"dotenv": "^8.2.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"simple-git": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.5.0.tgz",
|
||||
"integrity": "sha512-4gmtMqfIL9bsBNJDP/rDwZe3GsQL/tp85Qv5cmRc8iIDNOZJS4IX1oPfcqp9b7BGPc5bfuw4yd1i3lQacvuqDQ==",
|
||||
"requires": {
|
||||
"@kwsites/exec-p": "^0.4.0",
|
||||
"debug": "^4.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
package.json
Normal file
15
package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node --experimental-top-level-await --experimental-specifier-resolution=node -r dotenv-safe/config src"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"date-fns": "^2.14.0",
|
||||
"dotenv-safe": "^8.2.0",
|
||||
"simple-git": "^2.5.0"
|
||||
}
|
||||
}
|
||||
47
src/index.js
Normal file
47
src/index.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import git from 'simple-git/promise';
|
||||
import subDays from 'date-fns/fp/subDays';
|
||||
import getUnixTime from 'date-fns/fp/getUnixTime';
|
||||
import fromUnixTime from 'date-fns/fp/fromUnixTime';
|
||||
import isWeekend from 'date-fns/fp/isWeekend';
|
||||
|
||||
const {
|
||||
GITHUB_ACTOR,
|
||||
GITHUB_REPOSITORY,
|
||||
GITHUB_TOKEN,
|
||||
GIT_EMAIL,
|
||||
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',
|
||||
|
||||
ORIGIN_TIMESTAMP = getUnixTime(new Date()),
|
||||
MAX_DAYS = 1,
|
||||
INCLUDE_WEEKDAYS = true,
|
||||
INCLUDE_WEEKENDS = true,
|
||||
} = process.env;
|
||||
|
||||
const repoPath = `https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@${GIT_HOST}/${GITHUB_REPOSITORY}`;
|
||||
const localPath = './clone';
|
||||
const secondLine = 'Committed via https://github.com/marketplace/actions/contribution-graph';
|
||||
const dayOffsets = [...Array(Number(MAX_DAYS)).keys()];
|
||||
const originDay = fromUnixTime(ORIGIN_TIMESTAMP);
|
||||
|
||||
await git().clone(repoPath, localPath, ['--single-branch', '-b', GIT_BRANCH]);
|
||||
await git(localPath).env({GIT_SSH_COMMAND});
|
||||
await git(localPath).addConfig('user.name', GITHUB_ACTOR);
|
||||
await git(localPath).addConfig('user.email', GIT_EMAIL);
|
||||
|
||||
const commitCreators = dayOffsets
|
||||
.map((dayOffset) => subDays(dayOffset, originDay))
|
||||
.filter((day) => !(!JSON.parse(INCLUDE_WEEKENDS) && isWeekend(day)))
|
||||
.filter((day) => !(!JSON.parse(INCLUDE_WEEKDAYS) && !isWeekend(day)))
|
||||
.map((day) => async () => {
|
||||
const {commit: sha} = await git(localPath).commit([GIT_COMMIT_MESSAGE, secondLine], {
|
||||
'--allow-empty': null,
|
||||
'--date': `format:iso8601:${day.toISOString()}`,
|
||||
});
|
||||
console.log(`Successfully committed ${sha}`);
|
||||
});
|
||||
|
||||
await commitCreators.reduce((p, nextPromise) => p.then(nextPromise), Promise.resolve());
|
||||
await git(localPath).push(repoPath, GIT_BRANCH);
|
||||
Reference in New Issue
Block a user