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

Add 'payload' field to allow for Repository Dispatch #341

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

peckjon
Copy link

@peckjon peckjon commented Mar 25, 2023

Currently, actions/add-to-project cannot be used via repository_dispatch (or workflow_dispatch) since it retrieves all event-related information from the immediate github context, which is distinct from the dispatching workflow context.

This PR adds the ability to pass relevant context information from a dispatching workflow to a target workflow, and provides relevant documentation & code samples.

@peckjon peckjon requested a review from a team as a code owner March 25, 2023 05:55
@omerbensaadon
Copy link
Contributor

Hey Jon! We would welcome this addition!

Do you mind adding some tests? I'll leave you some comments on the documentation

README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@omerbensaadon omerbensaadon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested a few changes docs-wise and adding some tests wouldn't hurt!

README.md Outdated Show resolved Hide resolved
@peckjon
Copy link
Author

peckjon commented Mar 31, 2023

Thanks @omerbensaadon ! Changes to README completed.

I'm not aware of a way to add a test using Repository Dispatch, since it takes flow control away from the current environment 😞

@@ -37,6 +37,7 @@ interface ProjectV2AddDraftIssueResponse {
}

export async function addToProject(): Promise<void> {
const payload = core.getInput('payload') ? JSON.parse(core.getInput('payload')) : github.context.payload
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const payload = core.getInput('payload') ? JSON.parse(core.getInput('payload')) : github.context.payload
const inputPayload = core.getInput('payload')
cont payload = inputPayload ? JSON.parse(inputPayload) : github.context.payload

@mattcosta7
Copy link
Contributor

Thanks @omerbensaadon ! Changes to README completed.

I'm not aware of a way to add a test using Repository Dispatch, since it takes flow control away from the current environment 😞

For the test here, I think it's ok to just test that side of the workflow changes.

Particularly we might add a new test that calls mockGetInput with the new 'payload' mock as well

a sample of other input mocks is here:

mockGetInput({
'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token',
})

that should at least validate that the code accepts a payload as input

@jon-nfc
Copy link

jon-nfc commented Aug 15, 2024

is this going to be merged?

This feature is a must for workflow_run triggers and will also enable a workaround for the action not working on fork repositories. see nofusscomputing/action_project#3.

This PR would offer a workaround for #163 and #189

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

Successfully merging this pull request may close these issues.

4 participants