Skip to content

Action to move issues into a project column with some conditions

License

Notifications You must be signed in to change notification settings

hungluu/move-tasks

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

Repository files navigation

move-tasks v3

Action to move issues / PRs between project columns with some conditions

Features:

  • 🚀 Super-fast with Github Graphql and restful APIs
  • ✨ Flexible use cases with our Instructor Query
  • 🏭 A part of ABux standard process (guideline coming soon)

Table of contents:

Usage

See action.yml

Example usage

Here is an example setup using this action, which required params. Details on params are shown on Params section:

...
steps:
  - uses: hungluu/move-tasks@v3
    with:
      actionToken: <action-token>
      project: <project>
      repository: <repository>
      fromCards: >
        $project
          > columns(name oneOf To, In progress)
          > cards
      toColumn: $project > columns(name is Done)

Params

Param actionToken

type: string

This is Github token with permission on Issues & Projects, which can be acquired from Personal access tokens

Param repository

type: string

Repository identifier, requires user / organization along (with examples)

  • user name/repo name (hungluu/move-tasks)
  • org name/repo name (abux/labs)

Param project

type: number | string

This can be project's id (number), name (string) for user / organization projects or even projects that belong to specific repository (with examples):

  • project id (1)
  • project name (Blocks or a partial like Blo)
  • repo's project id (hungluu/move-tasks/1)
  • repo's project name (hungluu/move-tasks/Blocks)

Param fromCards

type: string

This use instructor query query to retrive cards (definition) for moving into column

Example 1 Move all cards from both columns named In progress and To do:

fromCards: >
  $project
    > columns(name oneOf To, In progress)
    > cards

Example 2 Move only cards belonging to closed issues:

fromCards: >
  $project
    > columns
    > cards(contentState is closed)

Example 3 Move only cards belonging to pull requests:

fromCards: >
  $project
    > columns
    > cards(contentType is Pull Request)

Example 4 Move only cards with specific users (for example hungluu and tranquocthoai):

fromCards: >
  $project
    > columns
    > cards(author oneOf hungluu, tranquocthoai)

Param toColumn

type: string

This use instructor query query to retrive a column (definition)

Example 1 Column named Done:

toColumn: >
  $project
    > columns(name is Done)

Example 2 Column with issue number (the number displayed on Issue, for example #1) from event context:

toColumn: >
  $project
    > columns(contentNumber is ${{ github.context.issue.number }})

Instructor Query

Enable flexible approaches to retrieve resources based on query definitions from data sources (customizable to each project) (More information)

Query format

$dataSource.layer(field filter values)

Format break-down:

  • $dataSource For this particular action, available data sources are:

    • $project Everything about project info, columns and cards
    • $context To access action github context (For example $context)
  • layer A part / path from data source. for example this is the action's current layer structure:

    $project {
      columns [
        ...
        {
          cards: [...]
        }
      ]
    }
    
  • field Depends on layer's data, there are fields we can filter through conditions, for example columns' fields definition:

    • id Column id
    • name Column name
  • filter Filters indicate what types of condition should be applied to field. For this project they are:

    • oneOf <values> Field is one of the provided values (For example columns(name oneOf Done, Released))
    • is <value> Check field value (For example cards(contentAuthor is hungluu))
    • in <list> Check field value exists on another list (For example cards(contentAuthor in $context.repo.owner))
    • has Check if field is a list which contains particular value (For example cards(labels has release, wip))
    • hasText check if field is a string which contains a word / text (For example cards(name hasText abc)) (This filter is case insensitive)
    • matches check if field is a string which matches regex (For example cards(name matches /abc/i))

Query definitions

Card definition:

export interface IProjectCard {
  id: number
  contentId: number
  contentNumber: number // issue or PR number, displayed on UI, for example #14
  contentTitle: string
  contentType: string
  contentCreatedAt: string
  contentAuthor: string
  contentState: string
  // { assigneeId: assigneeName }
  contentAssignees: {[key: string]: string}
  // { labelId: labelName }
  contentLabels: {[key: string]: string}
}

Column definition:

export interface IProjectColumn {
  id: number
  name: string
  cards: IProjectCard[]
}

Contribution

All contributions are welcomed. Feel free to clone this project, make changes that your feel necessary and pull request anytime you want.

Install dependencies

yarn install

Run development build

yarn start

If you have any other suggestions, you can even open new issues with enhancement label.

🍺

About

Action to move issues into a project column with some conditions

Resources

License

Stars

Watchers

Forks

Packages

No packages published