-
Notifications
You must be signed in to change notification settings - Fork 85
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
Support repo.repo and repo.owner as template variables #114
Conversation
I see Either way care to add some tests and document the change in README? Finally, what are other keys in there? Any secrets we might be inadvertently exposing/logging? |
cc2d604
to
b315e0f
Compare
Correct, it is not bringing in the nested structure. Specifically, it is not bringing in the
The available variables on the So
Updating the README is a great idea, I actually spent a lot of time confused because the README implied that all the values from this list were available on the template but as I found out they were not. For tests, the current tests don't have anything special for all the different template variables so I didn't think it was necessary to add any new ones. This is something that should simply work especially since we count on GitHub not to change the context in a breaking way any time soon.
Discussed above already, you can see the keys in export declare class Context {
/**
* Webhook payload object that triggered the workflow
*/
payload: WebhookPayloadWithRepository;
/**
* Name of the event that triggered the workflow
*/
event: string;
sha: string;
ref: string;
workflow: string;
action: string;
actor: string;
constructor();
get issue(): {
issue_number: number;
owner: string;
repo: string;
};
get pullRequest(): {
pull_number: number;
owner: string;
repo: string;
};
get repo(): {
owner: string;
repo: string;
};
} We already had everything except for the "getter" methods. I guess maybe it was assumed I am already successfully using this code from my fork to use {{ repo.repo }} in a generalized template. |
👋 thanks for opening this @NathanielRN, and thanks @dblock for sharing some 💭 s 🙏
Yes, this was my assumption - but that's not actually true. Or (and bear with me, I wrote most of this Action a long time ago), the reasoning for not requiring that Would you mind adding a test, for specifically |
d225129
to
c0073b8
Compare
Thanks for you input on this! 😄
Yes that's very true, but I found in my use case we could avoid code change if we had access to these variables. Using these variables I was able to copy and paste the same template across multiple repos without any change: etc... All these repos use the same issue template, so some future work could include pushing these to their own repo where we can pull them in as a submodule. We wouldn't need to modify them at all if we had the We use this value to construct a path to a page on GitHub pages which needs the organization and repository name separate, something like this:
I added this to the test so that it would be obvious to others who try to use it! Didn't realize the test were so advanced that they created and compared against snapshots 😄 Really cool, I've added a test for this now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @NathanielRN - test looks great! I think your use-case makes sense, if only for the portability/easy re-use of templates. Thanks for your contribution 😊 I'll merge this in, but I'm going to wait a bit to release a new version to group it with a couple other minor updates. Shouldn't be long!
Published in https://github.com/JasonEtco/create-an-issue/releases/tag/v2.6.0! Thanks again for the contribution 🙌 |
Description
Adding the
repo: tools.context.repo,
to thetemplateVariables
allows us to use{{ repo.owner }}
and{{ repo.repo }}
in the issue template mark down.One example useful test-case with this is for constructing links to the
gh-pages
static web pages without having to hardcode these parameters or manipulate theGITHUB_REPOSITORY
variable:e.g.
https://{{ repo.owner }}.github.io/{{ repo.repo }}/path/to/my/pageindex.html
Fixes #106