Giter Site home page Giter Site logo

bcanseco / github-contribution-graph-action Goto Github PK

View Code? Open in Web Editor NEW
75.0 3.0 10.0 497 KB

๐Ÿ™ˆ This GitHub action will automatically push empty commits to one of your repositories.

Home Page: https://github.com/marketplace/actions/autopopulate-your-contribution-graph

License: MIT License

Dockerfile 13.18% JavaScript 86.82%
github-actions github-action contribution-graph contributions-graph contribution-spoofing contributions-chart

github-contribution-graph-action's Introduction

Contribution Graph Action

Maybe most of your coding happens on another version control host, like GitLab or Bitbucket. Maybe your company uses GitHub Enterprise but hasn't enabled unified contributions. Maybe you're looking for a new software development job and are worried that recruiters will prejudge you by your scarce contribution graph.
Or maybe you have other reasons. Whatever the case may be, you've come to the right place.

Quick start without leaving your browser โšก

  1. Create a new repo (preferably private unless you have no shame)
  2. Click on Create a new file
  3. In the Name your file... field, type in .github/workflows/main.yml
  4. Paste in one of the YAML file contents below, depending on what you want to do. Be sure to update GIT_EMAIL.
  5. Click the Commit new file button at the bottom of the page. You're all set!
    • Note that you must enable the option below in your contribution settings for private commits to count on the graph.

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 GitHub once a day ๐Ÿบ

# .github/workflows/main.yml

on:
  schedule:
  - cron: '0 12 * * *' # every day at noon

jobs:
  single-commit:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
    - uses: bcanseco/github-contribution-graph-action@v2
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        GIT_EMAIL: [email protected] # replace me

If you need help with cron job syntax, crontab guru is a great resource.

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.

# .github/workflows/main.yml

on: push

jobs:
  backfill-commits:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
    - uses: bcanseco/github-contribution-graph-action@v2
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        GIT_EMAIL: [email protected] # replace me
        MAX_DAYS: 365
        MIN_COMMITS_PER_DAY: 1
        MAX_COMMITS_PER_DAY: 5

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. ๐ŸŸฉ
GIT_EMAIL An email address associated with your GitHub account. Without this, contributions won't show up. Read more. ๐ŸŸฉ
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
MIN_COMMITS_PER_DAY The minimum integer number of commits to make per day (inclusive). Used by a pseudo-RNG. 1
MAX_COMMITS_PER_DAY The maximum integer number of commits to make per day (inclusive). Used by a pseudo-RNG. 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
FORCE_PUSH A boolean indicating whether or not to force push. WARNING: Setting this to true will clear out your repo on each run! false

Advanced environment variables ๐Ÿง™โ€โ™‚๏ธ

There's also some advanced environment variables you can provide. Click here!

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

How do I know this is secure? ๐Ÿ”’

Explore the code! It's tiny and there aren't many dependencies.

Speaking of dependencies, all production npm dependencies used by this GitHub Action are automatically audited 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.

- uses: bcanseco/github-contribution-graph-action@v2
+ uses: bcanseco/[email protected]

As far as data security, there's two sensitive pieces of data that this Action handles:

GITHUB_TOKEN ๐Ÿ”‘

GitHub has a great article 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 and scoped to one 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:

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Getting 403 errors? โŒ

Make sure your token has write permission for the contents scope. If you're using the examples in this README, this is already done for you.

You can alternatively set this as a repo-level default:

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.

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:

Contribute ๐Ÿ‘ช

PRs are welcome! Please read the contributing guide. This project is MIT licensed.

github-contribution-graph-action's People

Contributors

bcanseco avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

github-contribution-graph-action's Issues

Discussion for CUSTOM_TEXT feature

CUSTOM_TEXT is currently out of scope for a feature request because the proposed solution of deleting the entire repo and recreating it for the correct contribution history on a repo is outside the permissions of GITHUB_TOKEN. However, I think it's a super cool idea & I'd love to explore it more.

Unfortunately though, commits made on a GitHub repository will always show on the graph even if those commits are later removed through a force push.

According to the github contribution docs the commits that are counted in the graph are "in the repository's default branch". My first thought was that the commit history could be added to a different branch that replaces the repo's default branch, then the original default branch is deleted.

However: at a glance, it does not seem that the token is allowed to delete anything whatsoever? And It's unclear if it's allowed to change the default branch of a repo. ๐Ÿค”

Default branches on github are now named "main"

'backfill-commits' fails because there is no remote branch 'master' to clone in new repositories:

warning: Could not find remote branch master to clone.
fatal: Remote branch master not found in upstream origin

Basic configuration with multiple commits per day is failling

Using below config, the server is sending thousands of commits in less than 2 minutes.:

# .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: [email protected] # replace me
        MAX_DAYS: 365
        MIN_COMMITS_PER_DAY: 1
        MAX_COMMITS_PER_DAY: 5

Expected: Maximum of 5 commits.
Tested using v1.1.0 and v1.2.0

Workflow auto starts after first push

im using back fill graph action. after the fist commit the workflow starts and then ends successfully but after an interval it starts again and then again , it keeps on committing

im using this code below
` on: push

jobs:
backfill-commits:
runs-on: ubuntu-latest
steps:
- uses: bcanseco/github-contribution-graph-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_EMAIL: [email protected] # replace me
MAX_DAYS: 365
MIN_COMMITS_PER_DAY: 1
MAX_COMMITS_PER_DAY: 5
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.