{"id":15495669,"url":"https://github.com/probablykasper/readme-template-action","last_synced_at":"2025-04-22T20:49:24.440Z","repository":{"id":41450276,"uuid":"289132625","full_name":"probablykasper/readme-template-action","owner":"probablykasper","description":"Integrate GitHub API data in your README.md","archived":false,"fork":false,"pushed_at":"2023-08-29T13:31:06.000Z","size":227,"stargazers_count":14,"open_issues_count":1,"forks_count":12,"subscribers_count":2,"default_branch":"v1","last_synced_at":"2025-04-15T17:02:37.453Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/probablykasper.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-20T23:35:48.000Z","updated_at":"2025-02-26T22:25:20.000Z","dependencies_parsed_at":"2024-06-21T07:32:38.280Z","dependency_job_id":null,"html_url":"https://github.com/probablykasper/readme-template-action","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probablykasper%2Freadme-template-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probablykasper%2Freadme-template-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probablykasper%2Freadme-template-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/probablykasper%2Freadme-template-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/probablykasper","download_url":"https://codeload.github.com/probablykasper/readme-template-action/tar.gz/refs/heads/v1","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250323581,"owners_count":21411939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T08:18:27.705Z","updated_at":"2025-04-22T20:49:24.421Z","avatar_url":"https://github.com/probablykasper.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README Template\n\nAdd GitHub data to your `README.md`, or any other file.\n\nA GitHub action that provides template strings that are replaced with their respective values when the action runs.\n\nBy default, it takes `TEMPLATE.md` and outputs `README.md`.\n\n## Inputs\n\n| name         | required | type   | default         | description |\n| ------------ | ---      | ------ | --------------- | ----------- |\n| token        | yes      | string |                 | GitHub personal access token used to fetch data. Pass a secret by for instance using `${{ secrets.README_TEMPLATE_TOKEN }}`. [Go here](https://github.com/settings/tokens/new?scopes=read:user) to generate one with the `read:user` scope\n| template     | yes      | string | `\"TEMPLATE.md\"` | Template file path\n| readme       | yes      | string | `\"README.md\"`   | Output file path\n\n## Example usage\n\nCheck out [`EXAMPLE_TEMPLATE.md`](./EXAMPLE_TEMPLATE.md) and [`EXAMPLE_OUTPUT.md`](./EXAMPLE_OUTPUT.md) for more examples and their outputs.\n\nWorkflow:\n\n```yml\nname: Readme Template\non:\n  schedule:\n    - cron: '0 */2 * * *' # every 2 hours\n  push:\n    branches: [ master ]\njobs:\n  publish:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v2\n      with:\n        fetch-depth: 0\n    - name: Generate README.md\n      uses: probablykasper/readme-template-action@v1\n      with:\n        token: ${{ secrets.README_TEMPLATE_TOKEN }}\n        template: TEMPLATE.md\n        output: README.md\n    - name: Update README.md\n      run: |\n        if [[ \"$(git status --porcelain)\" != \"\" ]]; then\n          git config user.name \"GitHub Action\"\n          git config user.email \"action@github.com\"\n          git add .\n          git commit -m \"Auto-update README.md\"\n          git push\n        fi\n```\n\n`TEMPLATE.md`:\n\n````markdown\nMy most starred repos:\n| ⭐️Stars   | 📦Repo    | 📚Description |\n| --------- | ----------- | -------------- |\n{{ loop 3_MOST_STARRED_REPOS }}\n| {{ REPO_STARS }} | [{{ REPO_FULL_NAME }}]({{ REPO_URL }}) | {{ REPO_DESCRIPTION }} |\n{{ end 3_MOST_STARRED_REPOS }}\n````\n\nThis generates the following output in my case:\n\nMy most starred repos:\n\n| ⭐️Stars   | 📦Repo    | 📚Description |\n| --------- | ----------- | -------------- |\n| 10 | [probablykasper/chester-syntax](https://github.com/probablykasper/chester-syntax) | A pretty Atom syntax theme based on Lonely Planet colours |\n| 4 | [probablykasper/homebrew-tap](https://github.com/probablykasper/homebrew-tap) | My Homebrew casks and formulas |\n| 2 | [probablykasper/cryp](https://github.com/probablykasper/cryp) | Cryptocurrency portfolio tracker |\n| 1 | [probablykasper/notifier](https://github.com/probablykasper/notifier) | Flutter app for scheduling notifications |\n| 1 | [probablykasper/colorboy](https://github.com/probablykasper/colorboy) | Easy terminal coloring for Node.js, macOS/Linux |\n\n## Variables\n\n### Normal variables you can put into your template file\n\n| Variable                 | Example |\n| ------------------------ | ------- |\n| {{ USERNAME }}            | probablykasper\n| {{ NAME }}                | Kasper\n| {{ EMAIL }}               | email@example.com\n| {{ USER_ID }}             | MDQ6VXNlcjExMzE1NDky\n| {{ BIO }}                 | Fullstack developer from Norway\n| {{ COMPANY }}             | Microscopicsoft\n| {{ LOCATION }}            | Norway\n| {{ TWITTER_USERNAME }}    | probablykasper\n| {{ AVATAR_URL }}          | https://avatars0.githubusercontent.com/u/11315492?u=c501da00e9b817ffc78faab6c630f236ac2738cf\u0026v=4\n| {{ WEBSITE_URL }}         | https://kasper.space/\n| {{ SIGNUP_TIMESTAMP }}    | 2015-03-04T14:48:35Z\n| {{ SIGNUP_DATE }}         | March 4th 2015\n| {{ SIGNUP_DATE2 }}        | 2015-03-04\n| {{ SIGNUP_YEAR }}         | 2015\n| {{ SIGNUP_AGO }}          | 5 years ago\n| {{ TOTAL_REPOS_SIZE_KB }} | 707453\n| {{ TOTAL_REPOS_SIZE_MB }} | 707.5\n| {{ TOTAL_REPOS_SIZE_GB }} | 0.71\n| {{ TOTAL_REPOSITORIES }}  | 46\n| {{ CURRENT_REPO_FULL_NAME }} | probablykasper/readme-template-action\n\n### Variables you can put inside `repo` loops\n\n| Variable                     | Example |\n| ---------------------------- | ------- |\n| {{ REPO_NAME }}              | cpc\n| {{ REPO_FULL_NAME }}         | probablykasper/cpc\n| {{ REPO_DESCRIPTION }}       | Text calculator with support for units and conversion\n| {{ REPO_URL }}               | https://github.com/probablykasper/cpc\n| {{ REPO_HOMEPAGE_URL }}      | https://rust-lang.org/\n| {{ REPO_CREATED_TIMESTAMP }} | 2019-12-05T22:45:04Z\n| {{ REPO_PUSHED_TIMESTAMP }}  | 2020-08-20T20:13:22Z\n| {{ REPO_FORK_COUNT }}        | 2\n| {{ REPO_ID }}                | MDEwOlJlcG9zaXRvcnkyMjYyMDE5NTU=\n| {{ REPO_CREATED_DATE }}      | December 5th 2019\n| {{ REPO_CREATED_DATE2 }}     | 2019-12-05\n| {{ REPO_CREATED_YEAR }}      | 2019\n| {{ REPO_CREATED_AGO }}       | 9 months ago\n| {{ REPO_PUSHED_DATE }}       | August 20th 2020\n| {{ REPO_PUSHED_DATE2 }}      | 2020-08-20\n| {{ REPO_PUSHED_YEAR }}       | 2020\n| {{ REPO_PUSHED_AGO }}        | 3 days ago\n| {{ REPO_STARS }}             | 5\n| {{ REPO_LANGUAGE }}          | Rust\n| {{ REPO_OWNER_USERNAME }}    | probablykasper\n| {{ REPO_SIZE_KB }}           | 1268285\n| {{ REPO_SIZE_MB }}           | 1268.3\n| {{ REPO_SIZE_GB }}           | 1.27\n\n## Loops\n\nThese are the built-in loops you can use. Data is only fetched for loops you use.\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eLoop\u003c/td\u003e\n            \u003ctd\u003eType\u003c/td\u003e\n            \u003ctd\u003eDescription\u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n            \u003ctd\u003e\u003ccode\u003e3_MOST_STARRED_REPOS\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003erepos\u003c/td\u003e\n            \u003ctd\u003e\n                Fetches your 3 most starred repos.\n                Uses the following parameters:\n                \u003cpre\u003efirst: 3,\u003cbr\u003eprivacy: PUBLIC,\u003cbr\u003eownerAffiliations:[OWNER],\u003cbr\u003eorderBy: { field:STARGAZERS, direction: DESC }\u003c/pre\u003e\n            \u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n            \u003ctd\u003e\u003ccode\u003e3_NEWEST_REPOS\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003erepos\u003c/td\u003e\n            \u003ctd\u003e\n                Fetches your 3 most starred repos.\n                Uses the following parameters:\n                \u003cpre\u003efirst: 3,\u003cbr\u003eprivacy: PUBLIC,\u003cbr\u003eownerAffiliations:[OWNER],\u003cbr\u003eorderBy: { field:CREATED_AT, direction: DESC }\u003c/pre\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003e\u003ccode\u003e3_RECENTLY_PUSHED_REPOS\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003erepos\u003c/td\u003e\n            \u003ctd\u003e\n                Fetches your 3 most starred repos.\n                Uses the following parameters:\n                \u003cpre\u003efirst: 3,\u003cbr\u003eprivacy: PUBLIC,\u003cbr\u003eownerAffiliations:[OWNER],\u003cbr\u003eorderBy: { field:PUSHED_AT, direction: DESC }\u003c/pre\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n## Advanced usage\n\nCheck out [`EXAMPLE_TEMPLATE.md`](./EXAMPLE_TEMPLATE.md) and [`EXAMPLE_OUTPUT.md`](./EXAMPLE_OUTPUT.md) to see examples and their outputs.\n\nFor advanced usage, add a code block like this to your template:\n\n````markdown\n```js\n// {{ TEMPLATE: }}\nmodule.exports = {\n    // ... custom vairables/loops\n}\n// {{ :TEMPLATE }}\n````\n\n### List specific repos\nGet a list of specific repos\n\n```js\n  CUSTOM_PINNED_REPOS: {\n    type: 'specificRepos',\n    repos: [ 'vidl', 'golang/go', 'probablykasper/embler' ],\n  },\n```\n\n### Repos with custom parameters\nGet repos using custom parameters:\n\n```js\n  \"2_MOST_STARRED_REPOS\": {\n    type: 'repos',\n    params: `\n      first: 2,\n      privacy: PUBLIC,\n      ownerAffiliations:[OWNER],\n      orderBy: { field:STARGAZERS, direction: DESC },\n    `,\n  },\n```\n\n### Modify variables\nAdd a `modifyVariables` function to overwrite/add variables:\n\n```js\n  CUSTOM_PINNED_REPOS: {\n    type: 'specificRepos',\n    repos: [ 'vidl' ],\n    modifyVariables: function(repo, moment, user) {\n      repo.REPO_CREATED_MYDATE = moment(repo.REPO_CREATED_TIMESTAMP).format('YYYY MMMM Do')\n      return repo\n    },\n  },\n```\n\n### Custom queries\n\n```js\n  LATEST_VIDL_RELEASE: {\n    type: 'customQuery',\n    loop: false,\n    query: async (octokit, moment, user) =\u003e {\n      // You can do anything  you want with the GitHub API here.\n      const result = await octokit.graphql(`\n        query {\n          repository(name: \"vidl\", owner: \"${user.USERNAME}\") {\n            releases(last: 1) {\n              edges {\n                node {\n                  url\n                  publishedAt\n                  tagName\n                }\n              }\n            }\n          }\n        }\n      `)\n      const release = result.repository.releases.edges[0].node\n      const date = new Date(release.publishedAt)\n      // We have `loop: false`, so we return an object.\n      // If we had `loop: true`, we would return an array of objects.\n      return {\n        VIDL_RELEASE_TAG: release.tagName,\n        VIDL_RELEASE_URL: release.url,\n        VIDL_RELEASE_WHEN: moment(release.publishedAt).fromNow(),\n      }\n    }\n  }\n```\n\n## Dev instructions\n\nFirst, to get started:\n\n1. Install [Node.js](https://nodejs.org/)\n2. Run `npm install`\n3. [Go here](https://github.com/settings/tokens/new?scopes=read:user) to generate a GitHub personal access token with the `read:user` scope.\n4. Create a `.env` file like this, with your token:\n\n```env\nINPUT_TOKEN=mytoken\nINPUT_TEMPLATE=EXAMPLE_TEMPLATE.md\nINPUT_OUTPUT=EXAMPLE_OUTPUT.md\n```\n\nNow you can test the action by running the following command:\n\n```sh\nnpm run test\n```\n\nBuild:\n```sh\nnpm run build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprobablykasper%2Freadme-template-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprobablykasper%2Freadme-template-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprobablykasper%2Freadme-template-action/lists"}