Skip to content
file-text

GitHub Action

File Reader

v1.0.0 Latest version

File Reader

file-text

File Reader

Read the contents of a file

Installation

Copy and paste the following snippet into your .yml file.

              

- name: File Reader

uses: andstor/file-reader-action@v1.0.0

Learn more about this action in andstor/file-reader-action

Choose a version

file-reader-ation

GitHub Action to read the contents of a file

build-test

This is a GitHub Action to read the contents of a file. Give it a path to a file and it provides you with the file's contents, accessible through an output variable.

Usage

The following example workflow step will read the contents of the package.json file.

- name: "Read file contents"
  uses: andstor/file-reader-action@v1
  with:
    path: "package.json"

Options ⚙️

The following input variables options can/must be configured:

Input variable Necessity Description Default
path Required the path to the file to read.
encoding Optional the encoding of the file to read. utf8

Outputs

  • contents: The contents of the file.

Example

name: "Read file contents"

on: [push, pull_request]

jobs:
  file_contents:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v1

      - name: Read file contents
        id: read_file
        uses: andstor/file-reader-action@v1
        with:
          path: "package.json"

      - name: File contents
        run: echo "${ steps.read_file.outputs.contents }"

License

Copyright © 2020 André Storhaug

file-reader-action is licensed under the MIT License.