Skip to content

FidelusAleksander/state-labels

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

State Labels 🏷️

CI License: MIT Coverage

A GitHub Action that treats issue & pull request labels as a simple key-value store. Persist workflow state across jobs and events without external storage.

No database. No artifacts. Just labels with a structured naming convention.

Example

Set the value of phase to build

- uses: FidelusAleksander/state-labels@v1
  with:
    operation: set
    key: phase
    value: build

Then get the value in the same, or different workflow run

  - uses: FidelusAleksander/state-labels@v1
    id: phase
    with:
      operation: get
      key: phase

  - name: Use value
    run: echo "phase: ${{ steps.phase.outputs.value }}"

How it works 🧠

Labels are created using a structured format:

{prefix}{separator}{key}{separator}{value}

Defaults to: state::key::value

On set, any existing label for the same {prefix}{separator}{key} is removed first.

Only labels starting with the configured prefix are considered. Other repository labels remain untouched.

Inputs βš™οΈ

Input Description Required Default
operation One of get, get-all, set, remove Yes -
issue-number Issue or PR number to operate on (auto-detected from context if not provided) No -
key State key (needed for get, set, remove) No -
value State value (needed for set) No -
prefix Label prefix No state
separator Separator between prefix, key, value No ::
repository Repository in owner/repo format No ${{ github.repository }}
github-token Token used for API calls No ${{ github.token }}

Outputs πŸ“€

Output Description When returned
value Retrieved value (string/number) get
state All state as JSON string get-all
success Boolean indicating if operation succeeded all

Notes about success:

  • success = true β€” The requested operation completed logically (value found, state set/removed, etc.).
  • success = false and the step did NOT fail β€” A soft/expected domain miss (currently only: key not found for get / remove).
  • success = false and the step failed (the action marked the run with core.setFailed) β€” An operational error (invalid inputs, API/network failure, etc.).

This lets you branch on domain misses without treating them as full step failures:

Permissions πŸ”’

Minimum required permissions (repo-level or workflow permissions: block):

permissions:
  issues: write
  pull-requests: write

Usage examples πŸš€

Setting state values

- uses: FidelusAleksander/state-labels@v1
  with:
    operation: set
    key: status
    value: in-progress
- uses: FidelusAleksander/state-labels@v1
  with:
    operation: set
    key: review-count
    value: '3'

Getting a single value

- uses: FidelusAleksander/state-labels@v1
  id: get-status
  with:
    operation: get
    key: status
- name: Use value
  run: echo "Status: ${{ steps.get-status.outputs.value }}"

Getting all state

- uses: FidelusAleksander/state-labels@v1
  id: all
  with:
    operation: get-all
- name: Show state
  run: echo '${{ steps.all.outputs.state }}'

Example get-all output:

{
  "status": "in-progress",
  "review-count": 3,
  "env": "staging"
}

Removing state

- uses: FidelusAleksander/state-labels@v1
  with:
    operation: remove
    key: status

Custom label format

- uses: FidelusAleksander/state-labels@v1
  with:
    operation: set
    key: env
    value: production
    prefix: workflow
    separator: __

Creates label: workflow__env__production

About

A GitHub Action that leverages issue & pull request labels as a simple key-value store

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •