|
| 1 | +## Advanced example 1: automatic day/night switching + keeping output in other branch |
| 2 | + |
| 3 | +This alternative workflow generates two files, `day.svg` and `night.svg`, and pushes it to `output-3d-contrib` branch, keeping the main repo 'clean' from build artifacts. |
| 4 | + |
| 5 | +### 1. Create special repository. |
| 6 | + |
| 7 | +Create a repository on GitHub with the same name as your user name. |
| 8 | + |
| 9 | +* e.g. If the user name is `octocat`, create a repository named `octocat/octocat`. |
| 10 | +* ref. [Managing your profile README](https://docs.github.com/en/github/setting-up-and-managing-your-github-profile/managing-your-profile-readme) |
| 11 | + |
| 12 | +In this repository, do the following. |
| 13 | + |
| 14 | +### 2. Create `conf/github-profile-3d-contrib.json` file in your <username> repo: |
| 15 | +```json:conf/github-profile-3d-contrib.json |
| 16 | +[ |
| 17 | + { |
| 18 | + "type": "normal", |
| 19 | + "fileName": "day.svg", |
| 20 | + "backgroundColor": "#ffffff", |
| 21 | + "foregroundColor": "#00000f", |
| 22 | + "strongColor": "#111133", |
| 23 | + "weakColor": "gray", |
| 24 | + "radarColor": "#47a042", |
| 25 | + "growingAnimation": true, |
| 26 | + "contribColors": [ |
| 27 | + "#efefef", |
| 28 | + "#d8e887", |
| 29 | + "#8cc569", |
| 30 | + "#47a042", |
| 31 | + "#1d6a23" |
| 32 | + ] |
| 33 | + }, |
| 34 | + { |
| 35 | + "type": "rainbow", |
| 36 | + "fileName": "night.svg", |
| 37 | + "backgroundColor": "#00000f", |
| 38 | + "foregroundColor": "#eeeeff", |
| 39 | + "strongColor": "rgb(255,200,55)", |
| 40 | + "weakColor": "#aaaaaa", |
| 41 | + "radarColor": "rgb(255,200,55)", |
| 42 | + "growingAnimation": true, |
| 43 | + "saturation": "50%", |
| 44 | + "contribLightness": [ |
| 45 | + "20%", |
| 46 | + "30%", |
| 47 | + "35%", |
| 48 | + "40%", |
| 49 | + "50%" |
| 50 | + ], |
| 51 | + "duration": "10s", |
| 52 | + "hueRatio": -7 |
| 53 | + } |
| 54 | +] |
| 55 | +``` |
| 56 | + |
| 57 | +### 3. Create `.github/workflows/profile-3d-contrib.yml` workflow file in your <username> repo: |
| 58 | +```yaml:.github/workflows/profile-3d-contrib.yml |
| 59 | +name: generate 3d chart for profile contributions |
| 60 | +
|
| 61 | +on: |
| 62 | + # run automatically every 24 hours |
| 63 | + schedule: |
| 64 | + - cron: "0 */24 * * *" |
| 65 | + |
| 66 | + # allows to manually run the job at any time |
| 67 | + workflow_dispatch: |
| 68 | + |
| 69 | + # run on every push on the main branch |
| 70 | + # don't forget to change if you're using 'master' branch |
| 71 | + push: |
| 72 | + branches: |
| 73 | + - main |
| 74 | +
|
| 75 | +jobs: |
| 76 | + build: |
| 77 | + runs-on: ubuntu-latest |
| 78 | + name: generate-github-profile-3d-contrib |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v3 |
| 81 | + - uses: yoshi389111/github-profile-3d-contrib@0.7.1 |
| 82 | + env: |
| 83 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + USERNAME: ${{ github.repository_owner }} |
| 85 | + SETTING_JSON: conf/github-profile-3d-contrib.json |
| 86 | + |
| 87 | + # push the content of <build_dir> to a branch |
| 88 | + # the content will be available at https://raw.githubusercontent.com/<github_user>/<repository>/<target_branch>/<file> , or as github page |
| 89 | + - name: push SVGs to the output-3d branch |
| 90 | + uses: crazy-max/ghaction-github-pages@v3.1.0 |
| 91 | + with: |
| 92 | + target_branch: output-3d-contrib |
| 93 | + build_dir: profile-3d-contrib |
| 94 | + env: |
| 95 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 96 | +``` |
| 97 | + |
| 98 | +### 4. Edit `README.md` in your <username> repo, adding the following code: |
| 99 | +Do not forget to replace `<github_user>` and `<repository>` with your GitHub username. |
| 100 | +```html |
| 101 | +<p align="center" > |
| 102 | + <picture> |
| 103 | + <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/<github_user>/<repository>/output-3d-contrib/night.svg" /> |
| 104 | + <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/<github_user>/<repository>/output-3d-contrib/day.svg" /> |
| 105 | + <img alt="github profile contributions chart" src="https://raw.githubusercontent.com/<github_user>/<repository>/output-3d-contrib/day.svg" /> |
| 106 | + </picture> |
| 107 | +</p> |
| 108 | +``` |
0 commit comments