Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ BUG ]: Unable set custom Date field #84

Closed
1 task done
IvanC-Gambit opened this issue Dec 19, 2023 · 2 comments
Closed
1 task done

[ BUG ]: Unable set custom Date field #84

IvanC-Gambit opened this issue Dec 19, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@IvanC-Gambit
Copy link

IvanC-Gambit commented Dec 19, 2023

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/project-beta-automations@v2.2.1
        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/project-beta-automations@v2.2.1
        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/project-beta-automations@v2.2.1
        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/project-beta-automations@v2.2.1
        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/project-beta-automations@v2.2.1
        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/project-beta-automations@v2.2.1
        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/project-beta-automations@v2.2.1
        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

@IvanC-Gambit IvanC-Gambit added the bug Something isn't working label Dec 19, 2023
@IvanC-Gambit
Copy link
Author

looks to be user error not correctly using setting operation_mode: custom_field or using custom_field_values instead of status_value

@leonsteinhaeuser
Copy link
Owner

I'm glad you found a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants