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

Is it possible to store the output of the policy for later step in the workflow? #297

Closed
ACyphus opened this issue Apr 9, 2024 · 7 comments · Fixed by #336
Closed

Is it possible to store the output of the policy for later step in the workflow? #297

ACyphus opened this issue Apr 9, 2024 · 7 comments · Fixed by #336
Assignees
Labels

Comments

@ACyphus
Copy link

ACyphus commented Apr 9, 2024

@jamacku 👋 Thanks for working on this action—it's been incredibly helpful!

I'm curious if it's possible to access the result of the policy in a later workflow step? As well as applying a label, I'm trying to add a step to my workflow that also updates a GitHub project field, but I can't seem to access the results of the policy.

Any suggestions? Or is this not possible?

@jamacku
Copy link
Member

jamacku commented Apr 9, 2024

I am glad to hear that you found this GHA helpful.

This is not possible so far, but it should be possible to add/implement it. I would like to know more details about what output you would like to see. Also, some examples would be great.

Internally: The policy will define the labels that will be set at the end.
Q: Would it be enough for your use case to have access to the list of the labels that will be set via output?

There is also a plan to add support for discussion forms, but I haven't yet time to implement it:

@ACyphus
Copy link
Author

ACyphus commented Apr 9, 2024

So my use case is that I'm taking an issue form field input:

- type: dropdown
    id: team
    attributes:
      label: What does the security concern impact?
      description: What is at risk due to the concern?
      options:
        - Acme the company Acme company/employee data or Acme infrastructure
        - Acme products services or Acme customers
        - Unknown
    validations:
      required: false

I'm then using this action 💖 to convert that into more useful data:

- template: ['security-report.yml']
    section:
      - id: ['team']
        block-list: []
        label:
          - name: 'THOR IR'
            keys: ['Acme the company Acme company/employee data or Acme infrastructure']
          - name: 'PSIRT'
            keys: ['Acme products services or Acme customers']
          - name: 'PSIRT'
            keys: ['Unknown']

And setting a label on the issue 🎉

However, I also need to set a field called Team for this issue on a project. I can use something like https://github.com/github/update-project-action but I need to pass it a value to set for that project field. With stefanbuck/github-issue-parser I can access the outputs to use one as a value: https://github.com/stefanbuck/github-issue-parser?tab=readme-ov-file#action-outputs

This doesn't get me the data friendly output from the policy though! 😅


Q: Would it be enough for your use case to have access to the list of the labels that will be set via output?

Yes! If I were able to access a list of labels, or a specific label by a key that would be wonderful.

For example with the above policy and this action step:

- name: Set labels for security reports
  id: set-labels
  uses: redhat-plumbers-in-action/advanced-issue-labeler@v2
  with:
    issue-form: ${{ steps.issue-parser.outputs.jsonString }}
    template: 'security-report.yml'
    token: ${{ secrets.GITHUB_TOKEN }}

I'd love to be able to access a specific label with the policy id as the key ${{ steps.set-labels.outputs.labels.team }}

Or a list of labels with ${{ steps.set-labels.outputs.labels}}

@jamacku
Copy link
Member

jamacku commented Apr 9, 2024

Thank you for sharing the details. This sounds very reasonable. I can provide JSON output where key will be an id from issue form and value will be the label name.

Implementation could take me some time because I have some important work to do this week. 🙂

I'll try to prioritize this feature since it might be also useful for others.

Thank you for reaching out. 🙂

@jamacku jamacku self-assigned this Apr 10, 2024
@jamacku jamacku pinned this issue Apr 10, 2024
@jamacku jamacku linked a pull request Apr 17, 2024 that will close this issue
@jamacku
Copy link
Member

jamacku commented Apr 17, 2024

@ACyphus, I have tried to come up with a solution to your request. I have started with writing documentation in 2c9b726

I'm planning to have JSON output in the following format:

{
  "template": "bug.yml",
  "section": {
    "severity": [ "low" ],
    "priority": [ "high" ]
  }
}

Would such an output be sufficient for your use case? Thank you.

@ACyphus
Copy link
Author

ACyphus commented Apr 17, 2024

@jamacku I took a look at the pull request and this seems to exactly match my needs 💖 Thank you for working on this 🙌

@jamacku
Copy link
Member

jamacku commented Apr 18, 2024

@ACyphus labels and policy outputs are now available in the latest version:

I hope you can achieve your goals with them. Please feel free to contact me when you find out about some issues or if you have some RFEs.

@jamacku jamacku unpinned this issue Apr 23, 2024
@ACyphus
Copy link
Author

ACyphus commented May 2, 2024

@jamacku just wanted to follow up and say that this feature is working brilliantly! Thank you for implementing it 💖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants