Skip to content
play

GitHub Action

Sync closed task references

v1.2.0 Latest version

Sync closed task references

play

Sync closed task references

Marks issues and PRs referenced from checkbox lists as completed

Installation

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

              

- name: Sync closed task references

uses: jonabc/[email protected]

Learn more about this action in jonabc/sync-task-issues

Choose a version

[DEPRECATED]

GitHub's native markdown task lists were updated since this action was originally created to perform the same behaviors. This action has been deprecated and will not receive any future changes.

javscript-action status

Mark references to issues and PRs as complete

This GH Action finds checkbox list item cross-references to an issue or pull request from an event and marks the references as complete.

This action uses the GitHub GraphQL API to find references, and updates each reference's body. The action looks for checkbox list items that are unchecked and marks them completed

- [ ] <any text>(url | #number)<any text>

becomes

- [x] <any text>(url | #number)<any text>

When an issue or PR which is referenced as a checkbox list item is reopened, the action will mark all references as incomplete.

- [x] <any text>(url | #number)<any text>

becomes

- [ ] <any text>(url | #number)<any text>

Usage

Create a YAML file in the .github/workflows folder of your repository with the following content:

name: Cross off linked issues
on:
  # the closed event type causes unchecked checkbox references to be checked / marked complete
  # the reopened event type causes checked checkbox references to be unchecked / marked incomplete
  issues:
    types: [closed, reopened]

  # the action works on pull request events as well
  pull_request:
    types: [closed, reopened]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Cross off any linked issue and PR references
        uses: jonabc/sync-task-issues@v1
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

Required permissions

The default ${{ secrets.GITHUB_TOKEN }} token can be used only when both the closed issues or PRs and their references are in the same repo.

For cross-repo references, a personal access token with repo access is needed from a user account that can write to the all repositories containing references.

Inputs

  • github_token: the token to use for authenticated GitHub API requests
  • state: explicitly configure whether to mark references as complete or incomplete when the action is triggered
    • accepts either complete and incomplete

Outputs

  • mark_references_as: Either complete or incomplete, showing how references were marked by the action
  • references: The list of objects obtained from the GitHub API that referenced the current issue or PR
    • output using JSON.stringify, ex. [{ ... reference 1 }, { ... reference 2 }]
    • see graphql.js#fields for which data fields are fetched from the API
  • updated: A list of ${type}:${id} strings that identify which objects from references were updated
    • output using JSON.stringify, ex. ["Issue:1", "PullRequest:2"]