Skip to content

Add optional pr-number input#8

Merged
duarten merged 2 commits intoumani:masterfrom
pruett:pruett.optional-pr-number
Apr 19, 2020
Merged

Add optional pr-number input#8
duarten merged 2 commits intoumani:masterfrom
pruett:pruett.optional-pr-number

Conversation

@pruett
Copy link
Copy Markdown
Contributor

@pruett pruett commented Apr 19, 2020

Description:

This optional input allows users to run this action outside of the pull_request event context.

Reasoning:

Certain pipelines are not conducive to running solely inside the pull_request event. For example, we are creating a custom deployment event triggered by a Netlify webhook when the build succeeds on their end. After this event triggers, we'd then like to use the changed files of the PR alongside the deployed preview url.

⚠️ This code has not been tested outside of a few manual triggers. I will look to tighten that up if this is a desired addition to the codebase.

@pruett pruett marked this pull request as ready for review April 19, 2020 14:01
Copy link
Copy Markdown
Member

@duarten duarten left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Looks great, and it makes a lot of sense to decouple the action from a particular context.

src/main.ts Outdated
core.setFailed("Could not get pull request number from context, exiting")
core.setFailed(
`Could not get pull request from ${prNumberInput ? "the provided pr number" : "context"}, exiting`,
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Provided you have time, it would be nice to extract this to its own function, fetchPr(): Promise<SomePrType> or similar.

@duarten duarten merged commit 5306e1f into umani:master Apr 19, 2020
import { WebhookPayload } from "@actions/github/lib/interfaces"

const octokit = new Octokit()
type GetPullResponseDataType = GetResponseDataTypeFromEndpointMethod<typeof octokit.pulls.get>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I followed the process of generating the octokit here. Not sure if there's a cleaner way to do this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks good to me.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually, it doesn't seem to compile. The fix is easy though, I think we can just drop this type since it's compatible with WebhookPayload["pull_request"].

duarten pushed a commit that referenced this pull request Apr 19, 2020
This optional input allows users to run this action outside of the pull_request event context.

Certain pipelines are not conducive to running solely inside the pull_request event. For example, we are creating a custom deployment event triggered by a Netlify webhook when the build succeeds on their end. After this event triggers, we'd then like to use the changed files of the PR alongside the deployed preview url.
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.

2 participants