{"id":17001608,"url":"https://github.com/shresht7/read-file-action","last_synced_at":"2026-02-10T02:02:48.833Z","repository":{"id":37934838,"uuid":"471706499","full_name":"Shresht7/read-file-action","owner":"Shresht7","description":"A GitHub Action to read a file and export its contents 📄","archived":false,"fork":false,"pushed_at":"2024-12-01T19:19:50.000Z","size":228,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-19T17:47:22.362Z","etag":null,"topics":["github-actions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shresht7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2022-03-19T13:40:26.000Z","updated_at":"2024-09-29T09:28:39.000Z","dependencies_parsed_at":"2025-04-12T16:33:15.615Z","dependency_job_id":null,"html_url":"https://github.com/Shresht7/read-file-action","commit_stats":{"total_commits":82,"total_committers":3,"mean_commits":"27.333333333333332","dds":0.4390243902439024,"last_synced_commit":"6934b3e9f7a51ae2b11703b82b2cfcc78319b276"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Shresht7/read-file-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shresht7%2Fread-file-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shresht7%2Fread-file-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shresht7%2Fread-file-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shresht7%2Fread-file-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shresht7","download_url":"https://codeload.github.com/Shresht7/read-file-action/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shresht7%2Fread-file-action/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270083130,"owners_count":24523870,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["github-actions"],"created_at":"2024-10-14T04:25:31.934Z","updated_at":"2026-02-10T02:02:48.807Z","avatar_url":"https://github.com/Shresht7.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- ================ --\u003e\n\u003c!-- READ FILE ACTION --\u003e\n\u003c!-- ================ --\u003e\n\n\u003ch1 align='center'\u003e\n  Read File Action\n\u003c/h1\u003e\n\n\u003c!-- ================= --\u003e\n\u003c!-- REPOSITORY BADGES --\u003e\n\u003c!-- ================= --\u003e\n\n\u003cdiv align='center'\u003e\n\n[![Release](https://img.shields.io/github/v/release/Shresht7/read-file-action?style=for-the-badge)](https://github.com/Shresht7/Gist-Mirror/releases)\n[![License](https://img.shields.io/github/license/Shresht7/read-file-action?style=for-the-badge)](./LICENSE)\n\n\u003c/div\u003e\n\n\u003c!-- =========== --\u003e\n\u003c!-- DESCRIPTION --\u003e\n\u003c!-- =========== --\u003e\n\n\u003cp align='center'\u003e\n\u003c!-- slot: description  --\u003e\nA GitHub Action to read a file and export its contents\n\u003c!-- /slot --\u003e\n\u003c/p\u003e\n\n\u003c!-- =============== --\u003e\n\u003c!-- WORKFLOW BADGES --\u003e\n\u003c!-- =============== --\u003e\n\n\u003cdiv align='center'\u003e\n\n[![Test](https://github.com/Shresht7/read-file-action/actions/workflows/test.yml/badge.svg)](https://github.com/Shresht7/read-file-action/actions/workflows/test.yml)\n[![Validate](https://github.com/Shresht7/read-file-action/actions/workflows/validate.yml/badge.svg)](https://github.com/Shresht7/read-file-action/actions/workflows/validate.yml)\n[![Action Readme](https://github.com/Shresht7/read-file-action/actions/workflows/action-readme.yml/badge.svg)](https://github.com/Shresht7/read-file-action/actions/workflows/action-readme.yml)\n\n\u003c/div\u003e\n\n\u003c!-- ================= --\u003e\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003c!-- ================= --\u003e\n\n\u003cdetails\u003e\n\n\u003csummary align='center'\u003eTable of Contents\u003c/summary\u003e\n\n- [📖 Usage](#-usage)\n- [📋 Inputs](#-inputs)\n- [📋 Outputs](#-outputs)\n- [📃 Workflow Example](#-workflow-example)\n- [📑 License](#-license)\n\n\u003c/details\u003e\n\n---\n\n## 📖 Usage\n\nUse this action in a workflow step\n\n```yaml\n- name: read-file\n  id: read-file\n  uses: Shresht7/read-file-action@v1\n  with:\n    path: ./README.md\n```\n\nYou can then access the output contents using [expressions][1].\n\n`${{ steps.read-file.outputs.contents }}`\n\n\u003e Note: this assumes you set the id as `read-file`.\n\nYou can tell this action to automatically parse `yaml` or `json` by specifying the `parse` input.\n\n```yaml\n- name: read-file\n  id: read-file\n  uses: Shresht7/read-file-action@v1\n  with:\n    path: ./package.json\n    parse: json\n```\n\n\u003e You can also set `parse` to `true` to let the action automatically determine the file-extension.\n\nThe parsed contents will be available as a stringified JSON. This output can be used by [`fromJSON`][2] in an [expression][1] or `JSON.parse` in an action.\n\n---\n\n## 📋 Inputs\n\n\u003c!-- slot: inputs  --\u003e\n| Input   | Description                                                                                                                                                                                                |     Default |   Required   |\n| :------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------: | :----------: |\n| `path`  | Path to the file to read (can be a URL)                                                                                                                                                                    | `undefined` | **required** |\n| `parse` | Parse the file contents as `yaml` or `json`. If `true`, will try to automatically determine the file-extension. You can set it to `yaml` or `json` manually too. If `false`, it will return the raw string | `undefined` |              |\n\u003c!-- /slot --\u003e\n\n## 📋 Outputs\n\n\u003c!-- slot: outputs  --\u003e\n| Output     | Description              |\n| :--------- | :----------------------- |\n| `contents` | The contents of the file |\n\u003c!-- /slot --\u003e\n\n## 📃 Workflow Example\n\nThe following workflow snippet demonstrates how this action can be used to read a file and its contents can be used by other actions. The snippet itself is placed here using this action in conjunction with the [markdown-slots][3] action.\n\n\u003cdetails\u003e\n\n\u003csummary\u003eClick to show\u003c/summary\u003e\n\n\u003c!-- slot: example,   prepend: ```yaml, append: ``` --\u003e\n```yaml\n# ================\n# READ FILE ACTION\n# ================\n\nname: Read File Example\n\n# Activation Events\n# =================\n\non:\n  # When this workflow file changes\n  push:\n    branches:\n      - main\n    paths:\n      - .github/workflows/example-workflow.yml\n\n  # Manual workflow dispatch\n  workflow_dispatch:\n\n# Jobs\n# ====\n\njobs:\n  update-readme:\n    runs-on: ubuntu-latest\n    steps:\n      # Actions Checkout ✅\n      # ===================\n\n      - name: checkout\n        uses: actions/checkout@v3\n\n      # Read File 📄\n      # ============\n\n      - name: read-file\n        id: read-file\n        uses: Shresht7/read-file-action@v1\n        with:\n          path: .github/workflows/example-workflow.yml\n\n      # Markdown Slots 📋\n      # =================\n\n      - name: markdown-slots\n        id: markdown-slots\n        uses: Shresht7/markdown-slots@v1\n        with:\n          slots: |\n            - slot: example\n              content: ${{ toJSON(steps.read-file.outputs.contents) }}\n          # steps.read-file.outputs.contents is itself a YAML string (example-workflow.yml)\n          # which causes markdown-slots action to try and parse it as a part of content and fail.\n          # the toJSON function forces the results into a one-line string.\n\n      # Push Changes 🌎\n      # ===============\n\n      - name: check for changes\n        id: git-diff\n        run: |\n          if git diff --exit-code; then\n            echo \"::set-output name=changes_exist::false\"\n          else\n            echo \"::set-output name=changes_exist::true\"\n          fi\n\n      - name: push\n        if: ${{ steps.git-diff.outputs.changes_exist == 'true' }}\n        run: |\n          git config user.name 'github-actions[bot]'\n          git config user.email 'github-actions[bot]@users.noreply.github.com'\n          git add .\n          git commit -m 'Update README.md 📄'\n          git push\n\n```\n\u003c!-- /slot --\u003e\n\n\u003c/details\u003e\n\n---\n\n## 📑 License\n\n[MIT](./LICENSE)\n\n\u003c!-- LINKS --\u003e\n\n[1]: https://docs.github.com/en/actions/learn-github-actions/expressions\n[2]: https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson\n[3]: https://www.github.com/Shresht7/markdown-slots","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshresht7%2Fread-file-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshresht7%2Fread-file-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshresht7%2Fread-file-action/lists"}