Skip to content

Commit

Permalink
fix: Add read-file action (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Feb 27, 2024
1 parent cfc5793 commit 80c1a32
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/example-read-file.yaml
@@ -0,0 +1,27 @@
name: '📗 Example Set Output'

on:
workflow_dispatch:

permissions:
contents: read

jobs:
run-example:
runs-on: ubuntu-latest
steps:
- name: Read a File
id: read-file
uses: ./public/read-file
with:
path: 'README.md'

- name: Summary
uses: streetsidesoftware/actions/public/summary@v1
with:
text: |
# Summary
File:
```````````markdown
${{ steps.read-file.outputs.result }}
```````````
7 changes: 7 additions & 0 deletions public/read-file/README.md
@@ -0,0 +1,7 @@
## `read-file` Action

Read a file from the filesystem and return it in `output.result`.

Example:

<!--- @@inject: ../../.github/workflows/example-read-file.yaml --->
24 changes: 24 additions & 0 deletions public/read-file/action.yaml
@@ -0,0 +1,24 @@
name: read-file
description: Read a file and return the contents.

inputs:
path:
description: The path to the file to read.
required: true
outputs:
result:
description: The contents of the file.
value: ${{ steps.read-file.outputs.result }}
runs:
using: composite
steps:
- name: Read File
id: read-file
uses: actions/github-script@v3
env:
INPUT_PATH: ${{ inputs.path }}
with:
result-encoding: string
script: |
const fs = require('fs');
return fs.readFileSync(process.env.GITHUB_WORKSPACE + '/' + process.env.INPUT_PATH, 'utf8') };

0 comments on commit 80c1a32

Please sign in to comment.