-
Notifications
You must be signed in to change notification settings - Fork 7
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
POC: Combine slash-command-dispatch and conda-lock-command workflows #88
base: main
Are you sure you want to change the base?
Conversation
Consolidate the slash-command-dispatch and conda-lock-command workflows into a single GitHub Action workflow, aided by the conda-lock-refresh GitHub Action at https://github.com/weiji14/conda-lock-refresh/releases/tag/v0.1.0. Based on sample workflow at https://github.com/weiji14/conda-lock-refresh-demo/blob/0f280e78657578326ba74d9f13861235661fb2d9/.github/workflows/conda-lock.yml
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
condalock: | ||
# Only run on Pull Requests, when a comment with '/condalock' is made | ||
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/condalock') |
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.
This is the key part that ensures the workflow only runs on Pull Request comments starting with /condalock
. Note that this can only run when the conda-lock-command.yml
workflow file is on the default main
branch (see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment), so we'll need to merge this PR to test it.
For a demo of how this works, see weiji14/conda-lock-refresh-demo#6 (comment).
# Generate token from CryoInTheCloud bot | ||
- uses: tibdex/github-app-token@v1 | ||
id: generate-token | ||
with: | ||
app_id: ${{ secrets.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} |
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.
We should be able to remove the secrets later, but best to keep it for a few weeks in case we need to revert this Pull Request due to some unforseen bugs.
@yuvipanda or @scottyhq, appreciate it if either of you take a look at this PR and give it a review. The PR should be keeping the same functionality of the If not, I can also just merge this in first and sort out any problems later 🙂 |
permissions: | ||
contents: write # for Git to git push | ||
contents: write # to git push added/changed files |
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.
Unfortunately these permissions don't seem to transfer to a fork such that the conda-lock step can't commit the lockfile (https://github.com/weiji14/conda-lock-refresh-demo/actions/runs/6176646925/job/16766044554).
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Error: Process completed with exit code 128.
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.
We worked around this originally by using a personal access token https://github.com/pangeo-data/pangeo-docker-images/blob/df4252f60bfc798f57323bdd86f0348ffce8fa4c/.github/workflows/ChatOpsDispatcher.yml#L13
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.
Yeah, I was afraid that the default GITHUB_TOKEN
wouldn't work from forks. Really wanted to avoid the need for setting up a Personal Access Token if possible, because it would be a lot of work for 2i2c to configure this across 100s of repos.
I've also considered setting up a GitHub App instead which has more permissions (https://docs.github.com/en/apps/creating-github-apps/about-creating-github-apps/deciding-when-to-build-a-github-app#choosing-between-a-github-app-or-github-actions), akin to what pre-commit CI is doing. That, or figuring out how conda-forge does it with their @conda-forge-admin, please rerender
command (unsure if this is only scoped to within the conda-forge
organization though).
This is neat @weiji14 I like creating a new action step. I think being able to run against forks is desirable for public projects. As far as I know the way to this is either to use a personal token or trigger the action from a label (which only repo admins can do & therefore the workflow can run with access to full secrets permissions) see https://github.com/uwhackweek/jupyterbook-template/blob/main/.github/workflows/netlifypreview.yaml |
Agree that we want this to work for public forks too. I'm gonna see if there's a workaround for the permissions part, from https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#changing-the-permissions-in-a-forked-repository, it says:
But that Let me have a think about what the best approach might be from all the options above. For this PR, I might end up sticking with |
To ensure that Pull Requests from forks can use the `/condalock` command too.
Making sure that the emoji reactions work on Pull Request forks.
Ok, using the GitHub App generated token again after 3046277 and 0c3a0ef. |
Consolidate the slash-command-dispatch and conda-lock-command workflows into a single GitHub Action workflow, aided by the conda-lock-refresh GitHub Action at https://github.com/weiji14/conda-lock-refresh/releases/tag/v0.1.0
References:
Closes #18, Supersedes #5