- Notifications
You must be signed in to change notification settings - Fork1.1k
chore: modify preview deployment script to work with forks#13404
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
… coder/coder repoSigned-off-by: Danny Kopping <danny@coder.com>
matifali commentedMay 30, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Does this make it work with forks and community contributors? We are using a few repo secrets in the deployment workflow, and I am not sure if this workflow allows forks to use the secret values. |
dannykopping commentedMay 30, 2024
I don't think so (at least that was not my intent), it just modified so that PRs created using forks would work. |
Signed-off-by: Danny Kopping <danny@coder.com>
| -name:Check if actor is a member | ||
| run:| | ||
| set -euo pipefail | ||
| response=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/orgs/coder/members/${{ github.actor }}") |
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.
Are you sure this works in each case? For example,https://api.github.com/orgs/coder/members/matifali returns
{"message":"User does not exist or is not a public member of the organization","documentation_url":"https://docs.github.com/rest/orgs/members#check-public-organization-membership-for-a-user"}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.
It seems like it works for private members:
$ curl -s -H"Authorization: token$(gh auth token)""https://api.github.com/orgs/coder/members/matifali" -v ...< HTTP/2 204 ...
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.
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.
Yes, all works great. I was testing without the token and always getting a 302. Thank you for adding the check.
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.
It would be nice to test by deploying the current PR.
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.
I tried that in#13280 (where I originally had this fix) but GH didn't seem to use the new workflow. Is there a timeout maybe? I'll give it a try though.
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.
Damn, I tried to execute this but I got:
$ ./scripts/deploy-pr.sh -d -b -y branchName: dk/fix-previewprNumber: 13404experiments: build:truedeploy:truecould not create workflow dispatch event: HTTP 422: No ref found for: dk/fix-preview (https://api.github.com/repos/coder/coder/actions/workflows/60960476/dispatches)
I think the branch has to be in the main repo.
Strange that I didn't get this before, though.
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.
Oh, looks like I must've pusheddk/verify-agent (the branch I was testing with previously) to themain repo somehow?
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.
I am noticing the same issue. It's deploying the previous branch I was working on.node-20
#13404 (comment)
dannykopping commentedMay 30, 2024
I've opened#13405 to validate. |
matifali commentedMay 30, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thank you. This is a good improvement. I plan to make this flow better sometimes#11331 |
matifali commentedMay 30, 2024
I tried deploying this PR but its detecting the wrong branch and PR number gh pr checkout 13404remote: Enumerating objects: 12, done.remote: Counting objects: 100% (12/12), done.remote: Compressing objects: 100% (2/2), done.remote: Total 12 (delta 10), reused 12 (delta 10), pack-reused 0Unpacking objects: 100% (12/12), 1.71 KiB | 877.00 KiB/s, done.From https://github.com/coder/coder * [new ref] refs/pull/13404/head -> dk/fix-previewSwitched to branch 'dk/fix-preview'git statusOn branch dk/fix-previewnothing to commit, working tree clean./scripts/deploy-pr.shAre you sure you want to deploy? (y/n) ybranchName: node-20prNumber: 12921experiments:build: falsedeploy: false✓ Created workflow_dispatch event for pr-deploy.yaml at node-20To see runs for this workflow, try: gh run list --workflow=pr-deploy.yaml |
dannykopping commentedMay 30, 2024
Weird, it works for me: $ gh pr status --repo=coder/coder --json headRefName,number --jq'.createdBy[0]'| cat{"headRefName":"dk/fix-preview","number":13404} |
matifali commentedMay 30, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Strangely for me but |
dannykopping commentedMay 30, 2024
Looking into it, |
dannykopping commentedMay 30, 2024
Can you try this@matifali? $ gh pr list --repo=coder/coder -H$(git rev-parse --abbrev-ref HEAD) --json number --jq'.[].number'| cat13404 |
dannykopping commentedMay 30, 2024
Alternatively we should skip the convenience and just accept a PR number as an argument. |
matifali commentedMay 30, 2024
|
Uh oh!
There was an error while loading.Please reload this page.
dannykopping commentedMay 30, 2024
I don't trust $ gh pr status --repo=coder/coder --json headRefName,number{"createdBy":[{"headRefName":"dk/fix-preview","number":13404},{"headRefName":"dk/verify-agent","number":13280}],"needsReview":[]}I think the script should just accept a PR as input. WDYT? |
Uh oh!
There was an error while loading.Please reload this page.
matifali commentedMay 30, 2024
@dannykopping I think as the branch is actually not on the |
dannykopping commentedMay 30, 2024
Not so for me: $ gh pr status --json headRefName,number --jq'.currentBranch'| cat |
dannykopping commentedMay 30, 2024
$ ./scripts/deploy-pr.sh -d -n -y dry runbranchName: dk/verify-agentprNumber: 13280experiments: build:falsedeploy:true$ git co dk/fix-preview Switched to branch'dk/fix-preview'$ ./scripts/deploy-pr.sh -d -n -ydry runbranchName: dk/fix-previewprNumber: 13404experiments: build:falsedeploy:true |
Signed-off-by: Danny Kopping <danny@coder.com>
matifali commentedMay 30, 2024
@dannykopping OK lets use |
dannykopping commentedMay 30, 2024
$ ./scripts/deploy-pr.sh -d Are you sure you want to deploy? (y/n) ybranchName: dk/fix-previewprNumber: 13404experiments: build:falsedeploy:truecould not create workflow dispatch event: HTTP 422: No ref found for: dk/fix-preview (https://api.github.com/repos/coder/coder/actions/workflows/60960476/dispatches) Same issue as before (not that I expected this to be fixed with this change, but worth noting). |
matifali commentedMay 30, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
It works fine now in dry run. Can you try deploying from the fork for real? So that we can test if all secrets are accessible, too. |
matifali commentedMay 30, 2024
Same issue for me. Can not deploy. |
matifali commentedMay 30, 2024
I think we need to allow running this workflow on forks in repo settings. |
dannykopping commentedMay 30, 2024
I think this is actually a good thing.
I think we'll have to close this PR. If the my branch from#13280 was not present in |
matifali commentedMay 30, 2024
Yes we do have the protection to check for membership but that check is part of the same workflow so not safe at all. |
Uh oh!
There was an error while loading.Please reload this page.
I maintain a fork of coder at
dannykopping/coder.When a branch exists in a fork only, the current preview deployment scripts break.
This PR modifies the script & action to reference the
coder/coderrepo explicitly for the PR.I also changed to
pr statusbecausepr viewdoes not work with--repo.