Skip to content

Latest commit

 

History

History
76 lines (58 loc) · 2.8 KB

README.md

File metadata and controls

76 lines (58 loc) · 2.8 KB

Upsert Issue

Create, update, reopen, or close a GitHub issue by title. Finds an existing issue with the same title and updates it, or creates a new one. Supports controlling the issue state (open / closed) to manage issue lifecycle — e.g., auto-closing when a report has no violations and reopening when violations recur.

When several issues share the title, the newest open one is used, otherwise the newest closed one. With open: "true", a closed match is reopened rather than duplicated, and the step fails if the reopen keeps failing, so a tracked problem is never left hidden behind a closed issue.

Inputs

Name Description Required Default
title Title of the issue to create or update ✅ —
body Body content of the issue ❌ —
body-file Path to a file containing the body content (takes precedence over body) ❌ —
labels Comma-separated list of labels to assign ❌ —
open Whether the issue should be open (true) or closed (false) ❌ true
close-comment Comment to post when closing the issue ❌ ✅ Resolved — closing this issue.
repository Target repository (owner/repo) ❌ ${{ github.repository }}
github-token GitHub token with issues: write permission ❌ ${{ github.token }}

Outputs

Name Description
issue-number The number of the created or updated issue
issue-url The URL of the created or updated issue

Usage

The containing job needs issues: write.

Create or update an issue

steps:
  - uses: devantler-tech/.github/actions/upsert-issue@<full-commit-sha> # vX.Y.Z
    with:
      title: "[report] My Report"
      body-file: report.md

Close an issue when resolved

steps:
  - uses: devantler-tech/.github/actions/upsert-issue@<full-commit-sha> # vX.Y.Z
    with:
      title: "[report] My Report"
      body: "No violations found."
      open: "false"
      close-comment: "✅ All violations have been resolved."

Conditional open/close based on a previous step

steps:
  - id: report
    run: bun run report:my-report

  - uses: devantler-tech/.github/actions/upsert-issue@<full-commit-sha> # vX.Y.Z
    with:
      title: "[report] My Report"
      body-file: ${{ steps.report.outputs.report-path }}
      open: ${{ steps.report.outputs.has-violations }}

Testing

Catalogue CI exercises the action's actual shell implementation against an offline GitHub CLI fixture in a job with only contents-read permission. Tests cover issue lifecycle, payloads and outputs, input validation, and API failures. They create no live smoke-test issue.

bash .github/tests/test-upsert-issue-reopen.sh
bash .github/tests/test-upsert-issue-ci.sh