|
1 | 1 | # github-contentful-readme
|
2 |
| -## This is a work in progress, and is not functional yet |
3 | 2 |
|
4 | 3 | [](https://www.gnu.org/licenses/gpl-3.0)
|
5 | 4 |
|
6 |
| - |
7 |
| - |
8 | 5 | ## About
|
9 | 6 |
|
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: |
17 | 8 |
|
18 |
| -### `subhead` |
| 9 | +- Header |
| 10 | +- Subheader |
| 11 | +- Footer |
| 12 | +- Website URL (formatted like a button) |
| 13 | +- Current position |
| 14 | +- Projects |
19 | 15 |
|
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: |
21 | 17 |
|
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) |
25 | 29 |
|
26 |
| -### `path` |
| 30 | +## Inputs |
27 | 31 |
|
28 |
| -Path of your README.md file. Default `"README.md"`. |
| 32 | +### `contentfulAccessToken` |
29 | 33 |
|
30 |
| -### `ref` |
| 34 | +**Required** Contentful content access token |
31 | 35 |
|
32 |
| -Override the default branch/tag ref. Default `"master"`. |
| 36 | +### `contentfulSpaceId` |
33 | 37 |
|
34 |
| -### `repoCount` |
| 38 | +**Required** Contentful space ID (not the name) |
35 | 39 |
|
36 |
| -Number of repositories to load. Default `"6"`. |
| 40 | +### `headerKey` |
37 | 41 |
|
38 |
| -### `reposPerRow` |
| 42 | +**Required** The name of the Key-Value pair in Contentful with the header text |
39 | 43 |
|
40 |
| -Number of repositories to load per row. Default `"3"`. |
| 44 | +### `subheaderKey` |
41 | 45 |
|
42 |
| -### `imageSize` |
| 46 | +The name of the Key-Value pair in Contentful with the subheader text |
43 | 47 |
|
44 |
| -Length (in pixels) of each side of the square image. Default `"150"`. |
| 48 | +### `footerKey` |
45 | 49 |
|
46 |
| -### `excludeActivity` |
| 50 | +The name of the Key-Value pair in Contentful with the footer text |
47 | 51 |
|
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` |
49 | 53 |
|
50 |
| -### `excludeRepo` |
| 54 | +The ID of the set of projects in Contentful to display |
51 | 55 |
|
52 |
| -Repositories to exclude from the recent activity table in a **JSON array**. Example input would be `'["theboi/theboi", "username/repo"]'`. Default `"[]"`. |
| 56 | +### `urlKey` |
53 | 57 |
|
54 |
| -### `customReadmeFile` |
| 58 | +The name of the Key-Value pair in Contentful with a URL for a website to link to |
55 | 59 |
|
56 |
| -Customise the README.md file format without forking this repository. Markdown supported. |
| 60 | +### `projectsLimit` |
57 | 61 |
|
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 |
63 | 63 |
|
64 |
| -```yaml |
65 |
| -Default: | |
66 |
| - ## ${header} |
67 |
| - |
68 |
| - ${subhead} |
69 |
| -
|
70 |
| - --- |
71 |
| - |
72 |
| - ${repoTable} |
73 |
| - |
74 |
| - --- |
75 |
| - |
76 |
| - ${footer} |
77 |
| -``` |
| 64 | +### `path` |
78 | 65 |
|
79 |
| -Note: `|` denotes a multiline string block in YAML. Ensure you indent properly when setting this. |
| 66 | +Path of your README.md file. |
80 | 67 |
|
81 | 68 | ## Environment Inputs
|
82 | 69 |
|
83 | 70 | ### `GITHUB_TOKEN`
|
84 | 71 |
|
85 | 72 | **Required** Set this to: `${{ secrets.GITHUB_TOKEN }}`
|
86 | 73 |
|
87 |
| -## Outputs |
88 |
| - |
89 |
| -### `repositories` |
90 |
| - |
91 |
| -Array of recent repositories to be displayed on your profile README.md. |
92 |
| - |
93 | 74 | ## Example usage
|
94 | 75 |
|
| 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 | + |
95 | 78 | - Article on Medium: https://medium.com/@theboi/how-to-dynamically-update-your-github-profile-readme-using-github-actions-684be5db9932
|
| 79 | + |
96 | 80 | - Create a repository named your username, add a `README.md` file.
|
97 | 81 | - Create a workflow and paste this under `steps`:
|
98 | 82 | ```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] |
101 | 86 | env:
|
102 | 87 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
103 | 88 | 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 }}``` |
108 | 97 | - You might want to schedule this to run every 10 mins, paste this under `on`:
|
109 | 98 | ```yaml
|
110 | 99 | schedule:
|
111 | 100 | - cron: "*/10 * * * *"
|
112 | 101 | ```
|
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. |
0 commit comments