Skip to content

Repository_dispatch jobs deploy master branch #41

@jessedobbelaere

Description

@jessedobbelaere

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions