Skip to content

taskworld/pr-metadata-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pr-metadata-action

Two composite GitHub Actions for stashing structured JSON inside a pull request body, hidden in an HTML comment. Useful for passing state between workflow runs without a separate store.

The metadata block looks like this and is invisible in the rendered PR description:

<!-- pr-meta: {"version":"1.2.3","reviewed":true} -->
  • read — extract the JSON from a PR body
  • write — write or merge JSON into the current PR body

Both are composite actions that wrap actions/github-script@v7. No build step, no extra setup.

read

Inputs

Name Required Default Description
github-token no ${{ github.token }} Token used for the REST API fallback
marker no pr-meta Marker name inside the HTML comment
pr-number no triggering PR PR number to read from. Defaults to the PR from the event

Outputs

Name Description
has-metadata "true" if the marker was found, "false" otherwise
result Parsed JSON, stringified. Empty string if the action failed

Example

on:
  pull_request:

jobs:
  read-metadata:
    runs-on: ubuntu-latest
    steps:
      - id: meta
        uses: taskworld/pr-meta-action/read@v1
      - run: echo '${{ steps.meta.outputs.result }}'
        if: steps.meta.outputs.has-metadata == 'true'

write

Must run on a pull_request event — it updates the PR body via the REST API.

Permissions

permissions:
  pull-requests: write

Inputs

Name Required Default Description
github-token no ${{ github.token }} Token used to update the PR body
marker no pr-meta Marker name inside the HTML comment
data yes JSON-stringified object to write under the marker
merge no "false" If "true", shallow-merge with existing metadata instead of replacing

When merge is true, both the existing and incoming values must be plain JSON objects.

Example

on:
  pull_request:

permissions:
  pull-requests: write

jobs:
  write-metadata:
    runs-on: ubuntu-latest
    steps:
      - uses: taskworld/pr-meta-action/write@v1
        with:
          data: '{"reviewed":true,"version":"1.2.3"}'
          merge: "true"

Notes

  • Both actions accept a custom marker, so you can store multiple independent JSON blobs in one PR body by using different names.
  • write is a no-op when the rendered body would be unchanged, so it's safe to run on every push.

About

a github action to read/write json in pr body

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors