Skip to content

Commit 1d64ce0

Browse files
committed
Add position, remove unused code, add information to README
1 parent 549bbe3 commit 1d64ce0

File tree

15 files changed

+251
-2707
lines changed

15 files changed

+251
-2707
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,6 @@ Thumbs.db
9797

9898
# Ignore built ts files
9999
__tests__/runner/*
100-
lib/**/*
100+
lib/**/*
101+
102+
notes

DISPLAY.jpg

-163 KB
Binary file not shown.

README.md

Lines changed: 53 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,102 @@
11
# github-contentful-readme
2-
## This is a work in progress, and is not functional yet
32

43
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
54

6-
![Example of profile README](https://raw.githubusercontent.com/theboi/github-update-readme/main/example.png)
7-
85
## About
96

10-
This GitHub Action updates your profile README.md to show your latest activity.
11-
12-
## Inputs
13-
14-
### `header`
15-
16-
**Required** The header of your README.md. Markdown supported.
7+
This GitHub Action updates your profile README.md based on data in the Contentful headless CMS. Right now it can show the following:
178

18-
### `subhead`
9+
- Header
10+
- Subheader
11+
- Footer
12+
- Website URL (formatted like a button)
13+
- Current position
14+
- Projects
1915

20-
The subheader of your README.md. Markdown supported. Default `""`.
16+
The code is built around my Contentful setup so it probably won't work for you out of the box, luckily it is easy to modify:
2117

22-
### `footer`
23-
24-
The footer of your README.md. Markdown supported. Default `""`.
18+
1. Edit `src/queries/readme.gql` to provide the data that you want to display
19+
2. Create `.env.contentful-codegen` with the following template, adding the corresponding values after the `=`:
20+
```env
21+
CONTENTFUL_CONTENT_TOKEN=
22+
CONTENTFUL_MANAGEMENT_TOKEN=
23+
CONTENTFUL_SPACE_ID=
24+
```
25+
3. Run `yarn gql-codegen` to generate TypeScript typings for your GraphQL objects (uses `fix-contentful-schema` so the required properties in the typings will match the required option in your Contentful content type definitions)
26+
4. Update any type/interface names in the files in the `src` directory that may have changed from the code generation
27+
5. Edit `src/main.ts` and `action.yml` to define the action inputs
28+
6. Edit `src/generate.ts` to use the values from the query (right now there's some code to handle key value pair objects but you can remove that if you want)
2529

26-
### `path`
30+
## Inputs
2731

28-
Path of your README.md file. Default `"README.md"`.
32+
### `contentfulAccessToken`
2933

30-
### `ref`
34+
**Required** Contentful content access token
3135

32-
Override the default branch/tag ref. Default `"master"`.
36+
### `contentfulSpaceId`
3337

34-
### `repoCount`
38+
**Required** Contentful space ID (not the name)
3539

36-
Number of repositories to load. Default `"6"`.
40+
### `headerKey`
3741

38-
### `reposPerRow`
42+
**Required** The name of the Key-Value pair in Contentful with the header text
3943

40-
Number of repositories to load per row. Default `"3"`.
44+
### `subheaderKey`
4145

42-
### `imageSize`
46+
The name of the Key-Value pair in Contentful with the subheader text
4347

44-
Length (in pixels) of each side of the square image. Default `"150"`.
48+
### `footerKey`
4549

46-
### `excludeActivity`
50+
The name of the Key-Value pair in Contentful with the footer text
4751

48-
Types of event to exclude from the recent activity table in a **JSON array**. Recent events, such as `"PushEvent"` or `"ForkEvent"`, can be found at https://api.github.com/users/{username}/events, replacing `username` with your username. Example input would be `'["WatchEvent", "ForkEvent"]'`. Default `"[]"`.
52+
### `setOfProjectsCollectionId`
4953

50-
### `excludeRepo`
54+
The ID of the set of projects in Contentful to display
5155

52-
Repositories to exclude from the recent activity table in a **JSON array**. Example input would be `'["theboi/theboi", "username/repo"]'`. Default `"[]"`.
56+
### `urlKey`
5357

54-
### `customReadmeFile`
58+
The name of the Key-Value pair in Contentful with a URL for a website to link to
5559

56-
Customise the README.md file format without forking this repository. Markdown supported.
60+
### `projectsLimit`
5761

58-
Use these reserved strings wrapped in `${` and `}` (For instance, `${header}`) to reference certain content:
59-
- `repoTable`: Set of tables with most recent repository activity.
60-
- `header`
61-
- `subhead`
62-
- `footer`
62+
The limit of the number of projects to display
6363

64-
```yaml
65-
Default: |
66-
## ${header}
67-
68-
${subhead}
69-
70-
---
71-
72-
${repoTable}
73-
74-
---
75-
76-
${footer}
77-
```
64+
### `path`
7865

79-
Note: `|` denotes a multiline string block in YAML. Ensure you indent properly when setting this.
66+
Path of your README.md file.
8067

8168
## Environment Inputs
8269

8370
### `GITHUB_TOKEN`
8471

8572
**Required** Set this to: `${{ secrets.GITHUB_TOKEN }}`
8673

87-
## Outputs
88-
89-
### `repositories`
90-
91-
Array of recent repositories to be displayed on your profile README.md.
92-
9374
## Example usage
9475

76+
This article applies to the repository that this is based on. Most of it will also apply to this repository but you will need to make changes to the parameters and `uses` field, see the example below.
77+
9578
- Article on Medium: https://medium.com/@theboi/how-to-dynamically-update-your-github-profile-readme-using-github-actions-684be5db9932
79+
9680
- Create a repository named your username, add a `README.md` file.
9781
- Create a workflow and paste this under `steps`:
9882
```yaml
99-
- name: Update GitHub Profile README
100-
uses: theboi/github-update-readme@v1.0
83+
- name: Update README
84+
id: github-contentful-readme
85+
uses: Merlin04/github-contentful-readme@v[Insert latest release here, see https://github.com/Merlin04/github-contentful-readme/releases]
10186
env:
10287
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10388
with:
104-
header: "Hey, I'm Ryan! 👋"
105-
subhead: "Currently a student in Singapore, passionate about creating all-things-tech to improve society."
106-
footer: "**Learn more about me at [ryanthe.com](https://www.ryanthe.com)!**"
107-
```
89+
headerKey: "github-header"
90+
subheaderKey: "github-subheader"
91+
footerKey: "github-footer"
92+
setOfProjectsCollectionId: "projects-collection-id"
93+
urlKey: "website-url"
94+
projectsLimit: 4
95+
contentfulAccessToken: ${{ secrets.CONTENTFUL_ACCESS_TOKEN }}
96+
contentfulSpaceId: ${{ secrets.CONTENTFUL_SPACE_ID }}```
10897
- You might want to schedule this to run every 10 mins, paste this under `on`:
10998
```yaml
11099
schedule:
111100
- cron: "*/10 * * * *"
112101
```
113-
- This will now run and fetch repositories you were most recently active on, every 10 mins.
114-
- **Important** Add a `DISPLAY.jpg` to your repositories (including username/username) to show in the table. If image does not exist, will default to `DISPLAY.jpg` on username/username.
115-
116-
## Note
117-
118-
- Due to GitHub's API rate-limiting, this GitHub Action will, at most, only check your 1000 most recent activities.
119-
- This is also my first GitHub Action so feel free to suggest improvements/submit a PR. Thanks!
102+
- This will now run, updating your README with the latest values from Contentful, every 10 mins.

__tests__/main.test.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

action.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,6 @@ inputs:
3737
description: 'Path of your README.md file.'
3838
required: false
3939
default: 'README.md'
40-
ref:
41-
description: 'Override the default branch/tag ref.'
42-
required: false
43-
default: 'master'
44-
imageSize:
45-
description: 'Length (in pixels) of each side of the square image.'
46-
required: false
47-
default: '200'
48-
excludeActivity:
49-
description: "Types of event to exclude from the recent activity table. Read more on this repository's README.md."
50-
required: false
51-
default: '[]'
52-
excludeRepo:
53-
description: "Repositories to exclude from the recent activity table. Read more on this repository's README.md."
54-
required: false
55-
default: '[]'
5640

5741
branding:
5842
icon: activity

business-24px.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)