Skip to content

Conversation

jonathansick
Copy link
Contributor

@jonathansick jonathansick commented Sep 27, 2021

This PR adds a "repository dispatch" step to the build workflow. What this does is trigger a GitHub Actions run in the astropy/learn-astropy repository. The payload for the trigger includes a reference to the workflow artifact, which will allow the learn-astropy build to download the tutorials artifact.

This requires a GitHub Secret to be set up on the tutorials repo named DISPATCH_GITHUB_TOKEN that has write access to the astropy/learn-astropy repository. See https://github.com/peter-evans/repository-dispatch#token

This PR adds a "repository dispatch" step to the build workflow. What
this does is trigger a GitHub Actions run in the astropy/learn-astropy
repository. The payload for the trigger includes a reference to the
workflow artifact, which will allow the learn-astropy build to download
the tutorials artifact.

This requires a GitHub Secret to be set up on the tutorials repo named
`DISPATCH_GITHUB_TOKEN` that has a write access to the
astropy/learn-astropy repository.
See https://github.com/peter-evans/repository-dispatch#token
This conservative versioning approach but prevents us from automatically
updating to a new version of repository-dispatch. Dependabot will help
us regularly re-evaluate the pin to get security and functionality
updates from peter-evans/repository-dispatch.
@jonathansick jonathansick marked this pull request as ready for review September 27, 2021 16:05
@jonathansick
Copy link
Contributor Author

@adrn Would you mind taking a look at this one? I don't think I can assign the review to you because of repo access.

Keep in mind that you'll also need to set up the GitHub Personal Access Token and add it as a secret. The token could come from a user account or a custom GitHub App installed into astropy/learn-astropy.

@adrn
Copy link
Contributor

adrn commented Sep 27, 2021

I don't think I can assign the review to you because of repo access.

Whoops! I just added you to the Learn Astropy Maintainers team - that was an oversight on my part...

Keep in mind that you'll also need to set up the GitHub Personal Access Token and add it as a secret. The token could come from a user account or a custom GitHub App installed into astropy/learn-astropy.

As in, when we merge this, right?

Copy link
Contributor

@adrn adrn left a comment

Choose a reason for hiding this comment

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

Cool, I think this looks good! So the DISPATCH_GITHUB_TOKEN should be a repo access token? With what privileges?

@adrn
Copy link
Contributor

adrn commented Sep 27, 2021

BTW: You might have permissions now to set up the token yourself?

@jonathansick
Copy link
Contributor Author

jonathansick commented Sep 28, 2021

Awesome, I added the secret to the repo. Right now I'm using a Personal Access Token, but unfortunately, I can't scope it to a specific repository. I'll make a to-do for myself to investigate writing a new action that runs through a custom GitHub App because that apps essentially create tokens that are scoped to specific orgs/repos.

For reference, the PAT has public_repo scope.

@pllim
Copy link
Contributor

pllim commented Sep 28, 2021

PAT is probably unavoidable. If necessary, another maintainer can refresh it in admin page.

https://docs.github.com/en/actions/security-guides/automatic-token-authentication#granting-additional-permissions

@adrn adrn merged commit 43ea361 into astropy-learn:main Sep 28, 2021
@jonathansick jonathansick deleted the add-workflow-dispatch branch September 28, 2021 15:18
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.

3 participants