Skip to content

Commit cd51794

Browse files
authored
Merge pull request #57 from tushev/main
Added 'advanced example'
2 parents 6698930 + e1f530f commit cd51794

File tree

2 files changed

+114
-1
lines changed

2 files changed

+114
-1
lines changed

EXAMPLES.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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+
```

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
This GitHub Action creates a GitHub contribution calendar on a 3D profile image.
1010

11-
## How to use (GitHub Actions)
11+
## How to use (GitHub Actions) - Basic
1212

1313
This action generate your github profile 3d contribute calendar and make a commit to your repo.
1414
You can also trigger action by yourself after add this action.
@@ -130,6 +130,10 @@ e.g.
130130
![](./profile-3d-contrib/profile-green-animate.svg)
131131
```
132132

133+
## How to use (GitHub Actions) - Advanced examples
134+
135+
#### [More info in EXAMPLES.md](./EXAMPLES.md)
136+
133137
## How to use (local)
134138

135139
Set the `GITHUB_TOKEN` environment variable to the value of "personal access token".
@@ -151,6 +155,7 @@ npm run build
151155
node . USER_NAME
152156
```
153157

158+
154159
## Licence
155160

156161
MIT License

0 commit comments

Comments
 (0)