Skip to content
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

Repository_dispatch jobs deploy master branch #41

Open
jessedobbelaere opened this issue Jun 24, 2022 · 2 comments
Open

Repository_dispatch jobs deploy master branch #41

jessedobbelaere opened this issue Jun 24, 2022 · 2 comments

Comments

@jessedobbelaere
Copy link

jessedobbelaere commented Jun 24, 2022

While #39 implemented support for repository_dispatch events, I don't see yet how to use it when someone makes a PR from his fork. I understand the concept of using /ok-to-test and dispatching via repository_dispatch.

However, when I print the variables in the okteto/deploy-preview job:

GITHUB_EVENT_NAME=repository_dispatch
GITHUB_REF_NAME=master
GITHUB_REF=refs/heads/master

Which contains master instead of the PR branch! And okteto/deploy-preview is figuring out the branch var to pass to the okteto deployer: https://github.com/okteto/deploy-preview/blob/main/entrypoint.sh#L34-L38 so it ends up passing the master branch to the okteto deployer.

So in the end this happens:

  1. Someone forks your repository and creates a PR
  2. You type /ok-to-deploy sha=XXX on the PR
  3. An ok-to-deploy action is triggered which triggers an okteto-preview-deploy action (via repository_dispatch)
  4. The bash script in okteto/deploy-preview incorrectly determines that master branch should be deployed based on GITHUB_REF based on this line
  5. A preview deploy is made using code from the latest master branch, not from the PR code changes

Any good suggestion to tackle this? I can make a PR, however I suppose we need to pass our custom own env var with the branch BRANCH since we don't have the PR number in the default env vars (it's dispatched)?

      - name: Deploy preview environment
        uses: okteto/deploy-preview@main
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
        with:
          name: ${{ env.DEPLOY_NAME }}

Did you also observe this @ikuradon ?

@pchico83
Copy link
Contributor

@jessedobbelaere which version of the action are you using?

@jessedobbelaere
Copy link
Author

jessedobbelaere commented Jun 27, 2022

Hi @pchico83, it's in the code snippet above, I'm using okteto/deploy-preview@main (because @latest is pointing to an outdated version #40 😛)

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

No branches or pull requests

2 participants