Git Product home page Git Product logo

leonsteinhaeuser / project-beta-automations Goto Github PK

View Code? Open in Web Editor NEW
81.0 3.0 24.0 78 KB

This automation provides the ability to automate issues and pull requests related to Github Projects (ProjectV2 / Beta). If the issue or pull request is not attached to a project, it is automatically added to the project and its desired column. In addition to status automation, this automation also supports custom field management.

License: MIT License

Shell 100.00%
project-management project-automation github-beta-issue github issue beta project pull-request issue-automation pull-request-automation

project-beta-automations's Introduction

project-beta-automations

latest release release date commits since release open: bugs open: feature requests issues closed license

This automation provides the ability to automate issues and pull requests related to Github Projects (Beta). If the issue or pull request is not attached to a project, it is automatically added to the project and its desired column. In addition to status automation, this automation also supports custom field management.

Note: GITHUB_TOKEN does not have the necessary scopes to access projects (beta). You must create a token with org:write scope and save it as a secret in your repository or organization. For more information, see Creating a personal access token.

⚠️ The GitHub API change of 2022-02-23 results in an error message requiring an upgrade to a new version.

What is the problem?

As of 2022-02-23 , the GitHub API requires that the value of a single select/iteration field be a string instead of an ID!

This causes the automation to throw an error message.

https://github.blog/changelog/2022-02-23-the-new-github-issues-february-23rd-update/

V1 vs V2

In June 2022, GitHub announced a breaking change to the Projects API. Therefore, the @v1 tag of this action will stop working on October 1, 2022. You can switch to the @v2 tag at any time (by updating the reference in your workflow file).

Project board

Since the issues and pull requests from this repository are also managed by this automation, you can take an example from the public project board to see what it looks like.

Project board.

Variables

Variable Required Description
gh_host false The GitHub hostname of the enterpise installation to use for the automation. For App instructions refer to GH App Auth.
gh_token false The GitHub token to use for the automation. For App instructions refer to GH App Auth. (gh_token or gh_app_* must be defined)
gh_app_ID false The GitHub App ID used for App authentication. For App instructions refer to GH App Auth. (gh_token or gh_app_* must be defined)
gh_app_installation_ID false The Github App installation ID binding the App to the target org. For App instructions refer to GH App Auth. (gh_token or gh_app_* must be defined)
gh_app_secret_key false The Github App Secret key used to sign App JWT tokens. For App instructions refer to GH App Auth. (gh_token or gh_app_* must be defined)
user false The GitHub username that owns the projectboard. Either a user or an organization must be specified.
organization false The GitHub organization that owns the projectboard. Either a user or an organization must be specified.
project_id true The projectboard id.
resource_node_id true The id of the resource node.
status_value false The status value to set. Must be one of the values defined in your project board Status field settings. If left unspecified, new items are added without an explicit status, and existing items are left alone.
operation_mode false The operation mode to use. Must be one of custom_field, status. Defaults to: status
custom_field_values false Provides the possibility to change custom fields. To be applied the operation_mode must be set to custom_field. For the json definition refer to JSON-Definition
move_related_issues false If set to true and the operation mode is set to status, the automation will also move related issues to the same column. This is useful if you want to move an issue to the same column as its related pull request. Defaults to: false

Getting started

The following example assumes that you have a project board with the following columns:

  • Todo
  • In Progress
  • Done

Before we start to automate the project board, we need to decide whether we want to manage the Status field using this action or the workflow definition of the project board. Keep in mind that until now there is no way to automatically add issues or pull requests to the project board using the provided workflow functionality by GitHub. The next example assumes that you decided to use this action to manage the Status field.

Current Status Target Status Event name GitHub event Description
any Todo issues github.event.action == 'opened', github.event.action == 'reopened' Define an automation that moves an issue to the Todo column.
any In Progress pull_request github.event.action == 'opened', github.event.action == 'reopened', github.event.action == 'review_requested' Define an automation that moves a pull request to the In Progress column.
any Closed issues, pull_request github.event.action == 'closed' Define an automation that moves an issue or pull request to the Done column.

The resulting workflow file is defined as follows:

name: Project automations
on:
  issues:
    types:
      - opened
      - reopened
      - closed
  pull_request:
    types:
      - opened
      - reopened
      - review_requested
      - closed

# map fields with customized labels
env:
  todo: Todo ✏️
  done: Done ✅
  in_progress: In Progress 🚧

jobs:
  issue_opened_or_reopened:
    name: issue_opened_or_reopened
    runs-on: ubuntu-latest
    if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'reopened')
    steps:
      - name: Move issue to ${{ env.todo }}
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          user: sample-user
          # organization: sample-org
          project_id: 1
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: ${{ env.todo }} # Target status
  issue_closed:
    name: issue_closed
    runs-on: ubuntu-latest
    if: github.event_name == 'issues' && github.event.action == 'closed'
    steps:
      - name: Moved issue to ${{ env.done }}
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          user: sample-user
          # organization: sample-org
          project_id: 1
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: ${{ env.done }} # Target status
  pr_opened_or_reopened_or_reviewrequested:
    name: pr_opened_or_reopened_or_reviewrequested
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'review_requested')
    steps:
      - name: Move PR to ${{ env.in_progress }}
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          user: sample-user
          # organization: sample-org
          project_id: 1
          resource_node_id: ${{ github.event.pull_request.node_id }}
          status_value: ${{ env.in_progress }} # Target status
  pr_closed:
    name: pr_closed
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    steps:
      - name: Move PR to ${{ env.done }}
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          user: sample-user
          # organization: sample-org
          project_id: 1
          resource_node_id: ${{ github.event.pull_request.node_id }}
          status_value: ${{ env.done }} # Target status

Allowing the workflow to run on PR's coming from forks

To allow PR from a fork to run the workflow use pull_request_target instead of pull_request like the example below.

name: Project automations

on:
  pull_request_target:
    types:
      - opened
      - closed

# map fields with customized labels
env:
  done: Done ✅
  in_progress: In Progress 🚧

jobs:
  pr_opened:
    name: pr_opened
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request_target' && github.event.action == 'opened'
    steps:
      - name: Move PR to ${{ env.in_progress }}
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          user: sample-user
          # organization: sample-org
          project_id: 1
          resource_node_id: ${{ github.event.pull_request.node_id }}
          status_value: ${{ env.in_progress }} # Target status
  pr_closed:
    name: pr_closed
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request_target' && github.event.action == 'closed'
    steps:
      - name: Move PR to ${{ env.done }}
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          user: sample-user
          # organization: sample-org
          project_id: 1
          resource_node_id: ${{ github.event.pull_request.node_id }}
          status_value: ${{ env.done }} # Target status

Without replacing pull_request by pull_request_target the workflow will fail with No GH Auth method configured, provide PAT or App ID/Key.

gh cli is installed.
Run echo "No GH Auth method configured, provide PAT or App ID/Key"; exit 1
  echo "No GH Auth method configured, provide PAT or App ID/Key"; exit 1
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    in_review: In Review
No GH Auth method configured, provide PAT or App ID/Key
Error: Process completed with exit code 1.

⚠️ Warning

For workflows that are triggered by the pull_request_target event, the GITHUB_TOKEN is granted read/write repository permission unless the permissions key is specified and the workflow can access secrets, even when it is triggered from a fork. Although the workflow runs in the context of the base of the pull request, you should make sure that you do not check out, build, or run untrusted code from the pull request with this event. Additionally, any caches share the same scope as the base branch. To help prevent cache poisoning, you should not save the cache if there is a possibility that the cache contents were altered.

GH App Auth

To leverage the App authentication with this action the following steps are needed:

  • Create a GitHub App under your user or organisation as described in the GitHub documentation, note the App ID
  • Set the needed GitHub App permissions in order for the newly create App to access and manage Org Project, as described in the GitHub documentation. The minimum required permissions are:
    • Repo: Actions: RW
    • Repo: Checks: RO
    • Repo: Contents: RO
    • Repo: Environments: RO
    • Repo: Issues: RW
    • Repo: Metadata: RO
    • Repo: PR: RW
    • Repo: Commit statuses: RO
    • Org: Members: RO
    • Org: Projects: RW
  • Create a private key to authenticate the newly created GitHub App as described in the GitHub documentation, treat the downloaded key as sensitive material, store it in a GitHub secret accessible by this action.
  • Install the app in the target organisation, note the installation ID
  • Configure this action with
    • gh_app_secret_key containing the aforementioned private key
    • gh_app_ID containing the app ID, auto-generated by GitHub in the first step
    • gh_app_installation_ID containing the installation ID, auto-generated by GitHub in the previous step. Binging the App to the Org

JSON-Definition

A single json object is defined as follows:

{
  "name": "Sample Text Field", # defines the name of the custom field
  "type": "text", # can be one of: text, number, date, single_select, iteration
  "value": "High" # defines the value to set (string)
}

The json definition that must be passed to the custom_field_values argument looks like:

[
  {
    "name": "Priority",
    "type": "single_select",
    "value": "High"
  }
  {
    "name": "Context",
    "type": "text",
    "value": "Just a random text"
  }
]

A detailed example can be found inside the test.sh file. Note that json definition must be enclosed in an array and escaped with double quotes and backslashes.

Example:

'[{\"name\": \"Priority\",\"type\": \"text\",\"value\": \"uuid1\"},{\"name\": \"Number\",\"type\": \"number\",\"value\": \"100\"},{\"name\": \"Date\",\"type\": \"date\",\"value\": \"2022-01-28T20:02:27.306+01:00\"},{\"name\": \"Single Select\",\"type\": \"single_select\",\"value\": \"Option 1\"},{\"name\": \"Iteration\",\"type\": \"iteration\",\"value\": \"Iteration 1\"}]'

The following example assumes that your project has the following fields defined:

  • Priority: As text field
  • Number: As number field
  • Date: As date field
  • Single Select: As single_select field with options:
    • Option 1
    • Option 2
    • Option 3
  • Iteration: As iteration field with iterations:
    • Iteration 1
    • Iteration 2
    • Iteration 3
name: Project automations (organization)

on:
  issues:
  pull_request:

env:
  gh_project_token: ${{ secrets.PAC_TOKEN }}
  project_id: 1
  gh_organization: sample-org
  status_todo: "Todo"
  status_in_progress: "In Progress"
  custom_field_values: '[{\"name\": \"Priority\",\"type\": \"text\",\"value\": \"uuid1\"},{\"name\": \"Number\",\"type\": \"number\",\"value\": \"100\"},{\"name\": \"Date\",\"type\": \"date\",\"value\": \"2022-01-28T20:02:27.306+01:00\"},{\"name\": \"Single Select\",\"type\": \"single_select\",\"value\": \"Option 1\"},{\"name\": \"Iteration\",\"type\": \"iteration\",\"value\": \"Iteration 1\"}]'

jobs:
  issue_opened_or_reopened:
    name: issue_opened_or_reopened
    runs-on: ubuntu-latest
    if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'reopened')
    steps:
      - name: 'Move issue to ${{ env.status_todo }}'
        uses: leonsteinhaeuser/[email protected]
        env:
          DEBUG_LOG: "true"
        with:
          gh_token: ${{ env.gh_project_token }}
          organization: ${{ env.gh_organization }}
          project_id: ${{ env.project_id }}
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: ${{ env.status_todo }}

  issue_project_custom_field_update:
    name: issue_opened_or_reopened
    runs-on: ubuntu-latest
    if: github.event_name == 'issues'
    needs:
      - issue_opened_or_reopened
    steps:
      - name: 'Modify custom fields'
        uses: leonsteinhaeuser/[email protected]
        env:
          DEBUG_LOG: "true"
        with:
          gh_token: ${{ env.gh_project_token }}
          organization: ${{ env.gh_organization }}
          project_id: ${{ env.project_id }}
          resource_node_id: ${{ github.event.issue.node_id }}
          operation_mode: custom_field
          custom_field_values: ${{ env.custom_field_values }}

  pr_opened_or_reopened:
    name: pr_opened_or_reopened
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened')
    steps:
      - name: 'Move PR to ${{ env.status_in_progress }}'
        uses: leonsteinhaeuser/[email protected]
        env:
          DEBUG_LOG: "true"
        with:
          gh_token: ${{ env.gh_project_token }}
          organization: ${{ env.gh_organization }}
          project_id: ${{ env.project_id }}
          resource_node_id: ${{ github.event.pull_request.node_id }}
          status_value: ${{ env.status_in_progress }}

  pr_custom_field_update_1:
    name: pr_custom_field_update_1 from env
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request'
    needs:
      - pr_opened_or_reopened
    steps:
      - name: 'Modify custom fields'
        uses: leonsteinhaeuser/[email protected]
        env:
          DEBUG_LOG: "true"
        with:
          gh_token: ${{ env.gh_project_token }}
          organization: ${{ env.gh_organization }}
          project_id: ${{ env.project_id }}
          resource_node_id: ${{ github.event.pull_request.node_id }}
          operation_mode: custom_field
          custom_field_values: ${{ env.custom_field_values }}

Since version 1.3.0 the iteration field also supports the following values:

  • @current: the current iteration
  • @next: the next iteration

Both of these values are provided by the project-beta-automations package. The following json provides an example of how to use these values:

Next iteration:

'[{\"name\": \"Iteration\",\"type\": \"iteration\",\"value\": \"@next\"}]'

Current iteration:

'[{\"name\": \"Iteration\",\"type\": \"iteration\",\"value\": \"@current\"}]'

Detailed example

Since this repository is also covered by this automation, you can take a look at the definition within the project-automation.yml file to check how it is defined here.

Debugging

Since debugging is key when tracing a bug, we decided to provide a two step debugging process. To enable the different debugging outputs, you can set the following environment variables:

Variable Option Default behaviour Description
DEBUG_COMMANDS true Do nothing Enables the stacktrace for command executions.
DEBUG_LOG true Do nothing Prints out the responses produced by the commands.

Example workflow definition:

env:
  todo: Todo ✏️
  gh_project_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
  user: sample-user
  project_id: 1

jobs:
  issue_opened:
    name: issue_opened
    runs-on: ubuntu-latest
    if: github.event_name == 'issues' && github.event.action == 'opened'
    steps:
      - name: Move issue to ${{ env.todo }}
        uses: leonsteinhaeuser/[email protected]
        env:
          DEBUG_COMMANDS: true
          DEBUG_LOG: true
        with:
          gh_token: ${{ env.gh_project_token }}
          user: ${{ env.user }}
          # organization: sample-org
          project_id: ${{ env.project_id }}
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: ${{ env.todo }}

project-beta-automations's People

Contributors

aarontwf avatar ericbsd avatar jaclynjessup avatar johnnyoshika avatar leonsteinhaeuser avatar matteomanzoni avatar mishagp avatar petrandr avatar satoshihirose avatar thingalon avatar weirdan avatar yinonov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

project-beta-automations's Issues

[Feature Request] Update to issue form

Is your feature request related to a problem? Please describe.

Describe the solution you'd like
issue form allows interactive issue template. let's use it!

Describe alternatives you've considered

Additional context

[ BUG ]: Action fails (due to token permissions), but shows as successful

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The action runs, and due to missing scopes fails to complete successfully with a number of warnings like:

Your token has not been granted the required scopes to execute this query. The 'name' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.

Expected Behavior

Action should clearly fail

Version

v2.0.0

Which github actions runner are you using?

Linux

Steps To Reproduce

  1. Token with [admin:org] and [repo] permissions
  2. Job defined thus:
jobs:
  issue_opened:
    name: issue_opened
    runs-on: ubuntu-latest
    steps:
      - name: 'Move issue to "Triage"'
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_token: ${{ secrets.MY_GITHUB_TOKEN }}
          organization: my-org
          project_id: 1
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: "Triage"

Relevant log output

2022-09-19T13:15:08.5608294Z Requested labels: ubuntu-latest
2022-09-19T13:15:08.5608341Z Job defined at: atsign-foundation/at_client_sdk/.github/workflows/autobug.yaml@refs/heads/trunk
2022-09-19T13:15:08.5608362Z Waiting for a runner to pick up this job...
2022-09-19T13:15:09.5206515Z Job is waiting for a hosted runner to come online.
2022-09-19T13:15:11.6726932Z Job is about to start running on the hosted runner: Hosted Agent (hosted)
2022-09-19T13:15:13.9073288Z Current runner version: '2.296.2'
2022-09-19T13:15:13.9105082Z ##[group]Operating System
2022-09-19T13:15:13.9105759Z Ubuntu
2022-09-19T13:15:13.9106109Z 20.04.5
2022-09-19T13:15:13.9106511Z LTS
2022-09-19T13:15:13.9106872Z ##[endgroup]
2022-09-19T13:15:13.9107262Z ##[group]Runner Image
2022-09-19T13:15:13.9107700Z Image: ubuntu-20.04
2022-09-19T13:15:13.9108035Z Version: 20220905.1
2022-09-19T13:15:13.9108698Z Included Software: https://github.com/actions/runner-images/blob/ubuntu20/20220905.1/images/linux/Ubuntu2004-Readme.md
2022-09-19T13:15:13.9109477Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu20%2F20220905.1
2022-09-19T13:15:13.9110024Z ##[endgroup]
2022-09-19T13:15:13.9110385Z ##[group]Runner Image Provisioner
2022-09-19T13:15:13.9110852Z 1.0.0.0-main-20220907-1
2022-09-19T13:15:13.9111233Z ##[endgroup]
2022-09-19T13:15:13.9112375Z ##[group]GITHUB_TOKEN Permissions
2022-09-19T13:15:13.9113259Z Actions: write
2022-09-19T13:15:13.9113846Z Checks: write
2022-09-19T13:15:13.9114261Z Contents: write
2022-09-19T13:15:13.9114663Z Deployments: write
2022-09-19T13:15:13.9115042Z Discussions: write
2022-09-19T13:15:13.9115468Z Issues: write
2022-09-19T13:15:13.9115861Z Metadata: read
2022-09-19T13:15:13.9116246Z Packages: write
2022-09-19T13:15:13.9116567Z Pages: write
2022-09-19T13:15:13.9116988Z PullRequests: write
2022-09-19T13:15:13.9117427Z RepositoryProjects: write
2022-09-19T13:15:13.9117860Z SecurityEvents: write
2022-09-19T13:15:13.9118206Z Statuses: write
2022-09-19T13:15:13.9118581Z ##[endgroup]
2022-09-19T13:15:13.9122930Z Secret source: Actions
2022-09-19T13:15:13.9123549Z Prepare workflow directory
2022-09-19T13:15:14.0129480Z Prepare all required actions
2022-09-19T13:15:14.0352131Z Getting action download info
2022-09-19T13:15:14.2825622Z Download action repository 'leonsteinhaeuser/[email protected]' (SHA:6ad2dc04dc4ca680c7e2583e9503708bd454e6a2)
2022-09-19T13:15:14.9631862Z Getting action download info
2022-09-19T13:15:15.1351533Z Download action repository 'actions/github-script@v3' (SHA:f05a81df23035049204b043b50c3322045ce7eb3)
2022-09-19T13:15:15.8173406Z ##[group]Run leonsteinhaeuser/[email protected]
2022-09-19T13:15:15.8173876Z with:
2022-09-19T13:15:15.8174459Z   gh_token: ***
2022-09-19T13:15:15.8174784Z   organization: atsign-foundation
2022-09-19T13:15:15.8175092Z   project_id: 8
2022-09-19T13:15:15.8175398Z   resource_node_id: I_kwDOElbMis5SIboF
2022-09-19T13:15:15.8175703Z   status_value: Triage
2022-09-19T13:15:15.8175997Z   operation_mode: status
2022-09-19T13:15:15.8176282Z ##[endgroup]
2022-09-19T13:15:15.8540150Z ##[group]Run /home/runner/work/_actions/leonsteinhaeuser/project-beta-automations/v2.0.0/deps.sh
2022-09-19T13:15:15.8541174Z �[36;1m/home/runner/work/_actions/leonsteinhaeuser/project-beta-automations/v2.0.0/deps.sh�[0m
2022-09-19T13:15:15.8611380Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2022-09-19T13:15:15.8611794Z ##[endgroup]
2022-09-19T13:15:15.8940146Z gh cli is installed.
2022-09-19T13:15:15.9139933Z ##[group]Run echo "***" | gh auth login --with-token
2022-09-19T13:15:15.9140762Z �[36;1mecho "***" | gh auth login --with-token�[0m
2022-09-19T13:15:15.9203162Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2022-09-19T13:15:15.9203544Z ##[endgroup]
2022-09-19T13:15:16.1773173Z ##[group]Run /home/runner/work/_actions/leonsteinhaeuser/project-beta-automations/v2.0.0/entrypoint.sh "organization" "status" "atsign-foundation" "8" "I_kwDOElbMis5SIboF" "Triage"
2022-09-19T13:15:16.1774003Z �[36;1m/home/runner/work/_actions/leonsteinhaeuser/project-beta-automations/v2.0.0/entrypoint.sh "organization" "status" "atsign-foundation" "8" "I_kwDOElbMis5SIboF" "Triage"�[0m
2022-09-19T13:15:16.1836733Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2022-09-19T13:15:16.1837112Z env:
2022-09-19T13:15:16.1837775Z   GITHUB_TOKEN: ***
2022-09-19T13:15:16.1838039Z ##[endgroup]
2022-09-19T13:15:16.4415132Z gh: Your token has not been granted the required scopes to execute this query. The 'projectV2' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.4418434Z Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.4446788Z PROJECT_UUID: null
2022-09-19T13:15:16.6865186Z gh: Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.6867156Z Your token has not been granted the required scopes to execute this query. The 'name' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.6868966Z Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.6873646Z Your token has not been granted the required scopes to execute this query. The 'name' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.6875514Z Your token has not been granted the required scopes to execute this query. The 'startDate' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.6877080Z Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.6878559Z Your token has not been granted the required scopes to execute this query. The 'title' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.6880047Z Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.6881535Z Your token has not been granted the required scopes to execute this query. The 'name' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.6883005Z Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.6885216Z Your token has not been granted the required scopes to execute this query. The 'name' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.9205672Z gh: Your token has not been granted the required scopes to execute this query. The 'addProjectV2ItemById' field requires one of the following scopes: ['project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.9207703Z Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:project'], but your token has only been granted the: ['admin:org', 'repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.
2022-09-19T13:15:16.9716084Z jq: error (at /tmp/api_organization_response.json:1): Cannot iterate over null (null)
2022-09-19T13:15:17.0190479Z jq: error (at /tmp/api_organization_response.json:1): Cannot iterate over null (null)
2022-09-19T13:15:17.0435231Z accepts 1 arg(s), received 81
2022-09-19T13:15:17.0645808Z Cleaning up orphan processes

Additional context:

Logs said that it needed [read:project], but that wasn't enough. For a successful run I then had to bump the token to having [project] (Full control of projects).

[BUG]: No Cards landing on my project board even though the action completes successfully

Describe the bug
Setup actions for new issue and closed issue to move to a "Backlog" and "Done" status column respectively.
Action completes successfully, but no card appears on my board.

I am seeing this in the output of the action logs:

Run leonsteinhaeuser/[email protected]
  with:
    gh_token: ***
    organization: MYORG
    project_id: 11
    resource_node_id: I_kwDOGtYcnM5Cfj4V
    status_value: Backlog
    operation_mode: status
  env:
    gh_project_id: 11
    gh_organization: MYORG
    proj_column_backlog: Backlog
    proj_column_done: Done
Run echo "***" | gh auth login --with-token
  echo "***" | gh auth login --with-token
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    gh_project_id: 11
    gh_organization: MYORG
    proj_column_backlog: Backlog
    proj_column_done: Done
Run /home/runner/work/_actions/leonsteinhaeuser/project-beta-automations/v1.1.0/entrypoint.sh "organization" "status" "MYORG" "11" "I_kwDOGtYcnM5Cfj4V" "Backlog"
  /home/runner/work/_actions/leonsteinhaeuser/project-beta-automations/v1.1.0/entrypoint.sh "organization" "status" "MYORG" "11" "I_kwDOGtYcnM5Cfj4V" "Backlog"
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    gh_project_id: 11
    gh_organization: MYORG
    proj_column_backlog: Backlog
    proj_column_done: Done
    GITHUB_TOKEN: ***
gh: Resource not accessible by integration
gh: Could not resolve to a node with the global id of 'null'
jq: error (at /tmp/api_response.json:0): Cannot iterate over null (null)
jq: error (at /tmp/api_response.json:0): Cannot iterate over null (null)
gh: Could not resolve to a node with the global id of 'null'

To Reproduce
Steps to reproduce the behavior:

  1. Using an organization name
  2. Using a project board ID. Can you add some detail into the docs on how to obtain the board ID properly? I'm assuming I'm using the correct integer, but that could be what's going wrong here.
  3. Using a ${{ secrets.GITHUB_TOKEN }}

Expected behavior
Issue cards appear on the project board in the proper status columns. I do not get any cards added anywhere to the project.

[BUG] "https://api.github.com/graphql": net/http: invalid header field value "token ***\n" for key Authorization

Describe the bug
The workflow runs successfully, however in the log output I see the following error:

Post "https://api.github.com/graphql": net/http: invalid header field value "token ***\n" for key Authorization

I have checked my PAT; it is not expired and has org:write rights. The strange thing is is that it has been working before. Also with update to the newest version of the workflow.

To Reproduce
Steps to reproduce the behavior:

env:
  status_todo: To Refine
  in_progress: Committed
  done: PR's to Review
  new: New
  custom_field_values: '[{\"name\": \"Iteration\",\"type\": \"iteration\",\"value\": \"Sprint 28\"}]'
  gh_organization: RoyalAholdDelhaize
  gh_project_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

jobs:
  job1:
    name: bug_opened_or_reopened
    runs-on: ubuntu-latest
    if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'reopened') && contains( toJson(github), 'bug' )
    steps:
      - name: 'Move issue to ${{ env.in_progress }}'
        uses: leonsteinhaeuser/[email protected]
        env:
          DEBUG_LOG: "true"
        with:
          gh_token: ${{ env.gh_project_token }}
          organization: ${{ env.gh_organization }}
          project_id: 46
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: ${{ env.in_progress }}

Expected behavior
The bug being added to the project board.

Workflow (please complete the following information):

  • OS: ubuntu-20.04
  • App version v1.2.1

Additional context
Add any other context about the problem here.

[ FEATURE REQUEST ]: Ability to clear custom fields

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe

Currently it is not possible to clear fields by for example setting it to null.

Describe the solution you'd like:

It would be great if a field could be removed by setting the value to for example null

Describe alternatives you've considered

Apparently, the GraphQL API needs a clear instruction. https://docs.github.com/en/graphql/reference/mutations#clearprojectv2itemfieldvalue

Additional context:

No response

[Feature Request]: Provide ability to relabel issues based on the project_card moved event or examples if already supported

Is your feature request related to a problem? Please describe.

User Story 1:
As a Project Manager, I want to manage labels on my issues automatically based upon the column I move an issue to. This will save everyone time and tedious manual effort.

User Story 2:
As a Developer, I have triaged an issue and have now labeled it with a particular status/category of issue. I would like my project board to reflect the work I did outside of the project board so the project is in-sync with the issue's status and visually represents this to the project team.

Describe the solution you'd like
I'm not sure if it's currently supported, but I'd like to see the ability to do 2 things:

  1. Upon moving to another status column, remove a particular label(s), and relabel with an additional label(s) based on status column the card gets moved to.
  2. If an issue is labeled outside of the Project, and it gets a particular label(s) move it to a column.

This may already be supported, but I think some examples in the documentation would really help provide some useful project automations.

[Feature Request] Ability to set custom fields (other than status) value

Is your feature request related to a problem? Please describe.
Some of our board view are driven by the value of a custom field, for example, grouping by field. We'd like to automatically fill that field out when assigning an issue to the board.

Describe the solution you'd like
It would be nice to be able to set custom fields value, in the same way we can currently set the status value, something like {custom_field_name}_value: value.

Describe alternatives you've considered
Looked around for another action that would support this, but have not found any.

[ FEATURE REQUEST ]: Ability to ignore the automation when issues are created via "Add Item +" button in the board

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe

I would like to keep the automation this project offers unless I create an issue through the "+ Add Item" button in the bottom of each column in the board.

When I create an issue through the button in a specific column, I would like to keep the issues in the same column.

Describe the solution you'd like:

When issues are created via "Add Item +", ignore the issue automation

Describe alternatives you've considered

When issues are created via "Add Item +", enable an alternative action separately from a normal issue automation

Additional context:

For more details, see #76

[ BUG ]: The single select option Id does not belong to the field

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

when using the custom_field_values variable getting error The single select option Id does not belong to the field

Expected Behavior

Custom field values should be set within the project when triggered

Version

v2.0.0

Which github actions runner are you using?

Windows

Steps To Reproduce

Technically using v2.0.1 but that is not within the drop down at this time.

  issue_labeled:
    name: issue_labeled
    runs-on: ubuntu-latest
    if: github.event_name == 'issues' && github.event.action == 'labeled'
    steps:
      - name: Add Issue to Contribution Board
        if: github.event.label.name == 'good first issue' || github.event.label.name == 'help wanted'
        uses: leonsteinhaeuser/[email protected]
        env:
          DEBUG_COMMANDS: true
          DEBUG_LOG: true
        with:
          gh_token: ${{ env.gh_project_token }}
          user: ${{ env.user }}
          project_id: ${{ env.gh_project_id }}
          resource_node_id: ${{ github.event.issue.node_id }}
          custom_field_values: '[{\"name\": \"Contributions\",\"type\": \"single_select\",\"value\": \"Yes\"}]'

Field set up in Project
project_field

Relevant log output

==========================   Debug mode is ON ==========================
PROJECT_UUID: ****
PROJECT_ITEM_UUID: ****
+ response='{data:{updateProjectV2ItemFieldValue:null},errors:[{type:VALIDATION,path:[updateProjectV2ItemFieldValue],locations:[{line:8,column:9}],message:The single select option Id does not belong to the field}]}'
+ log='\n{data:{updateProjectV2ItemFieldValue:null},errors:[{type:VALIDATION,path:[updateProjectV2ItemFieldValue],locations:[{line:8,column:9}],message:The single select option Id does not belong to the field}]}'
+ '[' true == true ']'
+ echo '==========================   Debug mode is ON =========================='
+ echo 'PROJECT_UUID: ****'
+ echo 'PROJECT_ITEM_UUID: ****'
+ echo -e 'log:\n\n{data:{updateProjectV2ItemFieldValue:null},errors:[{type:VALIDATION,path:[updateProjectV2ItemFieldValue],locations:[{line:8,column:9}],message:The single select option Id does not belong to the field}]}'
+ echo '==========================   Debug mode is ON =========================='
log:

{data:{updateProjectV2ItemFieldValue:null},errors:[{type:VALIDATION,path:[updateProjectV2ItemFieldValue],locations:[{line:8,column:9}],message:The single select option Id does not belong to the field}]}
==========================   Debug mode is ON ==========================

Additional context:

This can be seen with several different custom fields
custom_field_values: '[{\"name\": \"Type\",\"type\": \"single_select\",\"value\": \"🐛 Bug\"}]'

'[{\"name\": \"Priority\",\"type\": \"single_select\",\"value\": \"🌋 Urgent\"}, {\"name\": \"Sprint\",\"type\": \"iteration\",\"value\": \"@current\"}]'

This error can be seen on multiple projects. I have created a separate repo just to test and still receiving the error.

[ BUG ]: Incomplete Architecture Support

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Currently, the installation script (deps.sh) for the gh CLI only supports one architecture amd64.

This means that users on other architectures e.g. arm64 will not be able to use this automation.

Follows an example output while running the automation on an arm64 runner.

##[debug]/usr/bin/bash --noprofile --norc -e -o pipefail /home/ubuntu/actions-runner/_work/_temp/2d452a82-5f81-4399-8230-7d5468c9a0cc.sh
/home/ubuntu/actions-runner/_work/_temp/2d452a82-5f81-4399-8230-7d5468c9a0cc.sh: line 1: /usr/local/bin/gh: cannot execute binary file: Exec format error
Error: Process completed with exit code 126.

This occurs because the dep.sh installed the wrong arch version (amd64) of the gh cli on an arm64 system.

Expected Behavior

It is important to enhance the installation script to support a wider range of architectures. By doing so, we can ensure that users on various systems can easily use this automation without encountering architecture-related issues.

The expected behaviour is to extend the script to include support for the aarch64 architecture (for now).

With expanded architecture support, the installation script will automatically detect the system architecture and download the appropriate gh CLI binary for seamless installation.

Version

v1.0.2

Which github actions runner are you using?

Linux

Steps To Reproduce

  1. Install GitHub Runner on an arm-based system
  2. Register the runner in your account
  3. Use the automation

Relevant log output

##[debug]/usr/bin/bash --noprofile --norc -e -o pipefail /home/ubuntu/actions-runner/_work/_temp/2d452a82-5f81-4399-8230-7d5468c9a0cc.sh
/home/ubuntu/actions-runner/_work/_temp/2d452a82-5f81-4399-8230-7d5468c9a0cc.sh: line 1: /usr/local/bin/gh: cannot execute binary file: Exec format error
Error: Process completed with exit code 126.


### Additional context:

_No response_

[BUG] : gh: Resource not accessible by integration (App Authentication)

Hi, I'm trying to use a GH App to authenticate this workflow. The workflow completes successfully, but doesn't add issue to the project board. After going through the logs, I think I found the problem area:

++ gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f 'query=
    mutation($project:ID!, $resource_id:ID!) {
        addProjectNextItem(input: {projectId: $project, contentId: $resource_id}) {
            projectNextItem {
                id
            }
        }
    }' -f project=xxxxxxx -f resource_id=xxxxxxx --jq .data.addProjectNextItem.projectNextItem.id
gh: Resource not accessible by integration

I've double checked my bot permissions and they line up with what you wrote on the readme.

I've also done some debugging and have confirmed that the token is being properly authenticated.

Do you have any guidance as to why I'm getting the gh: Resource not accessible by integration output?

Some config info:

      - name: Move issue to ${{ env.todo }}
        env:
          DEBUG_COMMANDS: true
          DEBUG_LOG: true
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_app_secret_key: ${{ env.gh_app_secret_key }}
          gh_app_ID: ${{ env.gh_app_ID }}
          gh_app_installation_ID: ${{ env.gh_app_installation_ID }}

Much appreciated, thank you.

[BUG] status_value is required

The documentation states that status_value is not required, and that "If left unspecified, new items are added without an explicit status, and existing items are left alone.

However, when running the action without status_value set, I get the error Parameter 1: RESOURCE_NODE_VALUE is not set.

It looks like this line could be the culprit (it appears to be checking that the variable is not empty):

if [ -z "$RESOURCE_NODE_VALUE" ]; then

[BUG] entrypoint.sh: No such file or directory

Describe the bug
entrypoint.sh could not be found during ci run.

/home/runner/work/_temp/***bad6ff2-aced-44***2-bcb7-c13***b2cd6860.sh: line 1: ./entrypoint.sh: No such file or directory
Error: Process completed with exit code 127.

To Reproduce
Steps to reproduce the behavior:

  1. Define the workflow steps with values like
    steps:
      - name: 'Move issue to Todo'
        uses: leonsteinhaeuser/[email protected]
        with:
          github_token: $GITHUB_TOKEN
          organization: $ORGANIZATION
          project_id: $PROJECT_NUMBER
          resource_node_id: $ISSUE_ID
          status_value: "Todo"

Expected behavior
I expected to see the issue on my project board.

Workflow (please complete the following information):

  • OS: [e.g. ubuntu-latest]
  • App version [e.g. v0.0.1]

[ FEATURE REQUEST ]: Auto assign milestones

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe

Hello, I have been working with Iterations and this action handles really well setting the iteration upon issue creation, but I start working another project now and we use milestones there, I was wondering if we could add a functionality to auto assign the milestones to created issue.

Describe the solution you'd like:

When an issue is created I would like to see that most relevant milestone is assigned to the issue. ie having list of

  • 2.3.4
  • 2.3.5
  • 2.4.0

Action should assign the 2.3.4 since it is the closest release, there can be other options here about how to decide too, some people uses deadlines also but most of them not.

Describe alternatives you've considered

No response

Additional context:

No response

[ BUG ]: Unable set custom Date field

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I am unable to set a custom date field called "End" for my GitHub Project (Beta). The workflow, job, & steps appear to be successful, but when I check the date field in Projects Beta nothing has been set. I'm ultimately trying to set this date field dynamically based on the date when an issue is closed, but for now, I can't even get a manual date set using values specified in documentation: https://github.com/marketplace/actions/project-beta-automations#json-definition

Currently using version v2.2.1 but that option is not available in the template drop down.

Expected Behavior

I expect for my custom date field ("End") to have a value of 01-28-2022 when inspected in GitHub Projects (Beta).

Version

v2.0.1

Which github actions runner are you using?

Linux

Steps To Reproduce

Must have a Project (beta) with the following fields:

  • Status
    • Todo
    • In Progress
    • In Review
    • Done
  • Start
  • End
  • Iteration

Status is of type single select, Start & End are of type date, & Iteration is of type iteration.

Then, open an issue & then close to execute the following workflow stored in repository ./github/workflows/. Currently using a fork of project-beta-automations

issues.yml

name: Automatically Assign Project Properties for Issues

# Workflow triggers
on:
  issues:
    types:
      - opened
      - reopened
      - closed
  project_column:
    types:
      - moved
      - updated

# Initialize variables
env:
  org: Gambit-Defense
  gh_app_id: ${{ secrets.APP_ID }}
  gh_app_installation_ID: ${{ secrets.INSTALLATION_ID }}
  gh_app_secret_key: ${{ secrets.PRIVATE_KEY }}
  proj_id: 1
  todo: Todo
  in_progress: In Progress
  in_review: In Review
  done: Done
  iteration: '[{\"name\": \"Iteration\",\"type\": \"iteration\",\"value\": \"@current\"}]'
  end: '[{\"name\": \"End\",\"type\": \"date\",\"value\": \"2022-01-28T20:02:27.306+01:00\"}]'

# Workflows
jobs:

  # Set issue project status to todo do when issue is opened or reopened
  issue_todo:
    name: Issue Todo
    runs-on: ubuntu-latest
    if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'reopened') 
    steps:
      - name: Set Issue Project Status to ${{ env.todo }}
        uses: leonsteinhaeuser/[email protected]
        env:
          DEBUG_LOG: "true"
          DEBUG_COMMANDS: "true"
        with:
          gh_app_id: ${{ env.gh_app_id }}
          gh_app_installation_ID: ${{ env.gh_app_installation_ID }}
          gh_app_secret_key: ${{ env.gh_app_secret_key }}
          organization: ${{ env.org }}
          project_id: ${{ env.proj_id }}
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: ${{ env.todo }}

  # Update issue project iteration to current
  todo_iteration_update:
    name: Todo Iteration Update
    runs-on: ubuntu-latest
    needs: issue_todo
    steps:
      - name: Set ${{ env.todo }} Issue Project Iteration to Current
        uses: leonsteinhaeuser/[email protected]
        env:
          DEBUG_LOG: "true"
          DEBUG_COMMANDS: "true"
        with:
          gh_app_id: ${{ env.gh_app_id }}
          gh_app_installation_ID: ${{ env.gh_app_installation_ID }}
          gh_app_secret_key: ${{ env.gh_app_secret_key }}
          organization: ${{ env.org }}
          project_id: ${{ env.proj_id }}
          resource_node_id: ${{ github.event.issue.node_id }}
          operation_mode: custom_field
          custom_field_values: ${{ env.iteration }}

  # Set issue project status to in progress do when...
  # TODO: Determine appropriate trigger for this workflow WRT projects beta
  # Ref: https://github.com/orgs/community/discussions/40848
  issue_in_progress:
    name: Issue In Progress
    runs-on: ubuntu-latest
    if: github.event_name == 'issues' && (github.event.project_card.column_name == 'In Progress')
    steps:
      - name: Set Issue Project Status to ${{ env.in_progress }}
        uses: leonsteinhaeuser/[email protected]
        env:
          DEBUG_LOG: "true"
          DEBUG_COMMANDS: "true"
        with:
          gh_app_id: ${{ env.gh_app_id }}
          gh_app_installation_ID: ${{ env.gh_app_installation_ID }}
          gh_app_secret_key: ${{ env.gh_app_secret_key }}
          organization: ${{ env.org }}
          project_id: ${{ env.proj_id }}
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: ${{ env.in_progress }}
  
  # Update issue project iteration to current
  # TODO: Reuse todo_iteration_update workflow
  in_progress_iteration_update:
    name: In Progress Iteration Update
    runs-on: ubuntu-latest
    needs: issue_in_progress
    steps:
      - name: Set ${{ env.in_progress }} Issue Project Iteration to Current
        uses: leonsteinhaeuser/[email protected]
        env:
          DEBUG_LOG: "true"
          DEBUG_COMMANDS: "true"
        with:
          gh_app_id: ${{ env.gh_app_id }}
          gh_app_installation_ID: ${{ env.gh_app_installation_ID }}
          gh_app_secret_key: ${{ env.gh_app_secret_key }}
          organization: ${{ env.org }}
          project_id: ${{ env.proj_id }}
          resource_node_id: ${{ github.event.issue.node_id }}
          operation_mode: custom_field
          custom_field_values: ${{ env.iteration }}

  # Set issue project start date when issue is in progress
  # Note: no spaces in field list allowed in run statements or "nested mappings are not allowed in compact mappings" errors occur
  # Ref for date format: https://github.com/leonsteinhaeuser/project-beta-automations/issues/22#issuecomment-1003766896
  in_progress_start_date:
    name: In Progress Start Date
    runs-on: ubuntu-latest
    needs: [issue_in_progress, in_progress_iteration_update]
    if: github.event_name == 'issues' && (github.event.project_card.column_name == 'In Progress')
    steps:
      - name: Get & save current date to environmental variables
        run: echo "date=$(date --rfc-3339=ns | sed 's/ /T/; s/\(\....\).*\([+-]\)/\1\2/g')" >> $GITHUB_ENV
      - name: Set start date environmental variable
        run: start="[{\"name\":\"Start\",\"type\":\"date\",\"value\":\"DATE\"}]"
      - name: Update start date environmental variable
        # run: echo "start=\"${start/DATE/\"${{ env.date }}\"}\"" >> $GITHUB_ENV
        run: echo "start=\"${start/DATE/\"2022-01-28T20:02:27.306+01:00\"}\"" >> $GITHUB_ENV
      - name: Set ${{ env.in_progress }} Issue Project Start Date to ${{ env.date }}
        uses: leonsteinhaeuser/[email protected]
        env:
          DEBUG_LOG: "true"
          DEBUG_COMMANDS: "true"
        with:
          gh_app_id: ${{ env.gh_app_id }}
          gh_app_installation_ID: ${{ env.gh_app_installation_ID }}
          gh_app_secret_key: ${{ env.gh_app_secret_key }}
          organization: ${{ env.org }}
          project_id: ${{ env.proj_id }}
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: ${{ env.start }}

  # Set issue project status to done when issue is closed
  issue_done:
    name: Issue Done
    runs-on: ubuntu-latest
    if: github.event_name == 'issues' && github.event.action == 'closed'
    steps:
      - name: Set Issue Project Status to ${{ env.done }}
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_app_id: ${{ env.gh_app_id }}
          gh_app_installation_ID: ${{ env.gh_app_installation_ID }}
          gh_app_secret_key: ${{ env.gh_app_secret_key }}
          organization: ${{ env.org }}
          project_id: ${{ env.proj_id }}
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: ${{ env.done }}

  # Set issue project end date when issue is closed
  # Note: no spaces in field list allowed in run statements or "nested mappings are not allowed in compact mappings" errors occur
  # Ref for date format: https://github.com/leonsteinhaeuser/project-beta-automations/issues/22#issuecomment-1003766896
  done_end_date:
    name: Done End Date
    runs-on: ubuntu-latest
    needs: issue_done
    steps:
      # - name: Get & save current date to environmental variables
      #   run: echo "date=$(date --rfc-3339=ns | sed 's/ /T/; s/\(\....\).*\([+-]\)/\1\2/g')" >> $GITHUB_ENV
      # - name: Set end date environmental variable
      #   run: end="[{\"name\":\"End\",\"type\":\"date\",\"value\":\"DATE\"}]"
      # - name: Update end date environmental variable
      #   run: echo "end=\"${end/DATE/\"${{ env.date }}\"}\"" >> $GITHUB_ENV
      #   run: echo "end=\"${end/DATE/\"2022-01-28T20:02:27.306+01:00\"}\"" >> $GITHUB_ENV
      # - name: Set ${{ env.done }} Issue Project End Date to ${{ env.date }}
      - name: Set ${{ env.done }} Issue Project End Date to 2022-01-28T20:02:27.306+01:00
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_app_id: ${{ env.gh_app_id }}
          gh_app_installation_ID: ${{ env.gh_app_installation_ID }}
          gh_app_secret_key: ${{ env.gh_app_secret_key }}
          organization: ${{ env.org }}
          project_id: ${{ env.proj_id }}
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: ${{ env.end }}

Relevant log output

No response

Additional context:

No response

Automations start failing

Describe the bug
Since a couple of days, automations start failing with this error

gh: Type mismatch on variable $fieldOption and argument value (ID! / String!)
{errors:[{path:[mutation,updateProjectNextItemField,input,value],extensions:{code:variableMismatch,variableName:fieldOption,typeName:ID!,argumentName:value,errorMessage:Type mismatch},locations:[{line:13,column:17}],message:Type mismatch on variable $fieldOption and argument value (ID! / String!)}]}

To Reproduce
The step that throws that error:

      - name: 'Move PR to "🏗 PR Review"'
        if: github.event_name == 'pull_request' && github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'review_requested'
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          organization: Oztechan
          project_id: 2
          resource_node_id: ${{ github.event.pull_request.node_id }}
          status_value: "🏗 PR Review"

Expected behavior
It should continue to update the status of PR, like before it was doing.

Workflow (please complete the following information):

  • OS: ubuntu-latest
  • App version: @v1.0.1

[feature request] move linked issues together with the pull request

Describe the bug
I am trying to move an issue to "In review" on the project board, but it's not moving. My guess is that it's because the PR isn't the same as the issue id?

To Reproduce
Steps to reproduce the behavior:

  1. Define the workflow steps with values like
name: Project automations
on:
  issues:
    types:
      - opened
      - reopened
      - closed
  pull_request:
    types:
      - opened
      - reopened
      - review_requested
      - closed

# map fields with customized labels
env:
  backlog: Backlog
  in_progress: 🏗 In progress
  testing: Testing
  in_review: In review
  done: Done ✅

jobs:
  pr_opened_or_reopened_or_reviewrequested:
    name: pr_opened_or_reopened_or_reviewrequested
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'review_requested')
    steps:
      - name: Move PR to ${{ env.testing }}
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_token: xxxx
          organization: abc
          project_id: 3
          resource_node_id: ${{ github.event.pull_request.node_id }}
          status_value: ${{ env.testing }} # Target status

Expected behavior
The issue is moved to the "In review" lane.

[Feature Request] map variables against actual project values

Is your feature request related to a problem? Please describe.
not sure if #9 relates but it is common to change projects status values
e.g.
image

This breaks the pattern documented in the presented workflow.

Describe the solution you'd like
My suggestion is to have variables mapping the values or IDs used in the workflow against the actual ones

in_progress: In Progress 🚧

Additional context
it might be a no-brainer and a common custom implementation(?)

[Feature Request] Support for self-hosted runners, where `gh` client might not be present

On a self-hosted runner environment a lot of common tools are not available, such as the gh cli.

One workaround is to ensure an extra action that installs the gh before running the project-beta-automations action, but it would be nice for the action to test if the gh cli is present, and if not, download it from GitHub.

Below is the workaround we implemented in our org to allow the action to run in our self-hosted environment:

jobs:
  issue_opened_or_reopened:
    name: issue_opened_or_reopened
    runs-on: [self-hosted, ubuntu]
    if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'reopened')
    steps:
      - name: Install gh
        run: |
          curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
          echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
          sudo apt update
          sudo apt install gh
      - name: Move issue to Backlog
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_app_secret_key: ${{ secrets.GH_PROJ_AUTOMATION_KEY }}
          gh_app_ID: ${{ secrets.GH_PROJ_AUTOMATION_APP_ID }}
          gh_app_installation_ID: ${{ secrets.GH_PROJ_AUTOMATION_INSTALL_ID }}
          organization: ${{ env.gh_organization }}
          project_id: ${{ env.project_id }}
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: Backlog

[BUG] Unable to find the status_value_OPTION_ID, puts things in "No Status"

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Define the workflow steps with values like
  pr_ready_for_review:
    name: pr_ready_for_review
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request' && github.event.action == 'ready_for_review'
    steps:
      - name: 'Move PR to "Ready for Review"'
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_token: ${{ secrets.PAT_TOKEN }}
          organization: settlemint
          project_id: 20
          resource_node_id: ${{ github.event.pull_request.node_id }}
          status_value: "Ready for Review"
  1. log output
PROJECT_ID: PN_kwDOATEl-80WyQ
ITEM_ID: PNI_lADOATEl-80Wyc4AAm1J
STATUS_FIELD_ID: MDE2OlByb2plY3ROZXh0RmllbGQ0NTg0Ng==
status_value_OPTION_ID: 
{data:{updateProjectNextItemField:{projectNextItem:{id:PNI_lADOATEl-80Wyc4AAm1J}}}}
  1. board setup

CleanShot 2021-10-04 at 10 58 07

This is modeled after the readme, is there a way to see what options there are for the status_value_OPTION_ID?

[BUG] entrypoint.sh: local: can only be used in a function

Describe the bug
entrypoint.sh: local: can only be used in a function

entrypoint.sh: local: can only be used in a function

To Reproduce
Steps to reproduce the behavior:

  1. Define the workflow steps with values like
    steps:
      - name: 'Move issue to Todo'
        uses: leonsteinhaeuser/[email protected]
        with:
          github_token: $GITHUB_TOKEN
          organization: $ORGANIZATION
          project_id: $PROJECT_NUMBER
          resource_node_id: $ISSUE_ID
          status_value: "Todo"

Expected behavior
I expected to see the issue on my project board.

Workflow (please complete the following information):

  • OS: [e.g. ubuntu-latest]
  • App version [e.g. v0.0.3]

[ FEATURE REQUEST ]: Ability to configure what needs to be attached to a project/moved and what is not

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe

The ability to move linked issues with the PR is great!
But in my case, I don't need to attach PRs to the project and therefore don't need to put them in any columns.

Describe the solution you'd like:

It would be great to be able to configure whether to attach a PR to a project / move it or not.
Perhaps something like:

attach_pr: false # Specifies whether to attach a PR to the project (if not already attached)
move_pr: false # Specifies whether to move the PR

Describe alternatives you've considered

No response

Additional context:

No response

[ FEATURE REQUEST ]: Support for Enterprise Customers

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe

Currently, this automation plugin lacks support for enterprise customers. This limitation prevents enterprises from leveraging the full potential of the plugin in their workflows. To address this, I would like to request the addition of a new feature that enables support for enterprise customers.

Describe the solution you'd like:

Introduce an additional input parameter named gh_host in the actions.yml. This new input would allow users to specify the hostname of their enterprise GitHub instance. By including this parameter, users can authenticate and interact with their enterprise repositories seamlessly.

Additionally, modifying the existing gh login commands within the plugin to include the gh_host input would ensure that the authentication process aligns with the user's enterprise environment. This modification would enable seamless integration with enterprise GitHub instances and empower enterprise customers to fully utilize this plugin.

The gh_host must be the FQDN of the enterprise installation.

Example

name: Project automation on enterprise server
on:
  issues:
    types:
      - opened

env:
  todo: Todo ✏️

jobs:
  issue_opened_or_reopened:
    name: issue_opened_or_reopened
    runs-on: ubuntu-latest
    steps:
      - name: Move issue to ${{ env.todo }}
        uses: leonsteinhaeuser/[email protected]
        with:
          gh_host: my.github.example.com
          # gh_host: ${{ vars.GITHUB_ENTERPRISE_HOST }} 
          gh_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          user: sample-user
          # organization: sample-org
          project_id: 1
          resource_node_id: ${{ github.event.issue.node_id }}
          status_value: ${{ env.todo }} # Target status

Describe alternatives you've considered

No response

Additional context:

No response

[Feature Request] Add custom label while adding issue to a board

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
My use case is we have been using separate Project beta boards for subteams and I'm trying to create a consolidated main board. I still would like the subteams to be able to use the new consolidated board without extra noise and I'm hoping to they can use label filters to get a similar view. In order for this to work seamlessly however, I need the ability to add labels via workflow based on source repo | source board, etc.

Having the ability to define an extra variable e.g. 'add_labels' should unlock this use case.
Thank you!

[BUG] entrypoint.sh: line 9: project.sh: No such file or directory

Describe the bug
entrypoint.sh is not able to load project.sh

/home/runner/work/_actions/leonsteinhaeuser/project-beta-automations/v0.0.2/entrypoint.sh: line 9: project.sh: No such file or directory

To Reproduce
Steps to reproduce the behavior:

  1. Define the workflow steps with values like
    steps:
      - name: 'Move issue to Todo'
        uses: leonsteinhaeuser/[email protected]
        with:
          github_token: $GITHUB_TOKEN
          organization: $ORGANIZATION
          project_id: $PROJECT_NUMBER
          resource_node_id: $ISSUE_ID
          status_value: "Todo"

Expected behavior
I expected to see the issue on my project board.

Workflow (please complete the following information):

  • OS: [e.g. ubuntu-latest]
  • App version [e.g. v0.0.1]

[Feature Request] Support user based beta projects

Is your feature request related to a problem? Please describe.
I want to be able to automate beta projects owned by users

Describe the solution you'd like
Add a user input field

Describe alternatives you've considered
Tried other actions, they don't support beta projects

Additional context
Add any other context or screenshots about the feature request here.

[BUG] Cross-organization: 'This project item doesn't belong to correct owner'

Describe the bug
Hi there, we're loving this action so far for automatically adding all Issues/PRs for our organization-owned repositories to our private organization beta projects dashboard.

We'd also love to be able to do this for a handful of repositories that our organization manages, but do not 'own' (they are hosted by other GitHub organizations).

I was hoping that the organization field of the YAML would allow for this, but the links to the dashboard do not seem to be going through successfully, with the relevant output of the action (which passes) being:

gh: This project item doesn't belong to correct owner

To Reproduce
Relevant YAML: https://github.com/NeurodataWithoutBorders/nwbinspector/blob/66aa6c995f9151a619aa347bc44f7a19a14a26c5/.github/workflows/add-to-dashboard.yml

The MY_GITHUB_TOKEN is setup with permissions and this same workflow works correctly whenever it is used in a repository that organization owns.

Full action output: https://github.com/NeurodataWithoutBorders/nwbinspector/runs/6133081630?check_suite_focus=true

Expected behavior
I had hoped it would add the issues/PRs from the external repo to our private organization dashboard. If this isn't supported by this action workflow, just let me know.

Workflow (please complete the following information):

  • OS: ubuntu-latest
  • App version: 1.2.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.