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

Action checks out incorrect branch #5

Closed
jugglinmike opened this issue Aug 10, 2019 · 5 comments
Closed

Action checks out incorrect branch #5

jugglinmike opened this issue Aug 10, 2019 · 5 comments

Comments

@jugglinmike
Copy link

I am trying to use this Action from a Workflow which responds to the pull_request event. Specifically, I'd like it to check out the branch named master:

on: pull_request
name: Synchronize the Pull Request Preview
jobs:
  update-pr-preview:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master

However, the logs show that the Action is not checking out the master branch. Instead, it appears to be fetching the GitHub-specific "merge" reference for the pull request that triggered the Workflow. The following command is listed in the logs:

git -c http.extraheader="AUTHORIZATION: basic ***" fetch --tags --prune --progress --no-recurse-submodules origin +refs/heads/*:refs/remotes/origin/* +refs/pull/11/merge:refs/remotes/pull/11/merge

This is a problem for a couple reasons.

First, subsequent steps in the Workflow use secret values. I do not want to execute the untrusted code of a pull request in the presence of those values.

Second, many people (and the automated scripts in my project) delete the pull request branch immediately after closing the pull request, causing GitHub to delete the corresponding refs/pull/XX/merge git ref. That prevents the action from running under these conditions, even though I don't actually need the deleted ref.

@TingluoHuang
Copy link
Member

@jugglinmike

can you try:

steps:
    - uses: actions/checkout@v1.0.0
      with:
        ref: refs/heads/master

@peter-evans
Copy link
Contributor

Unless actions work differently now, the official documentation is incorrect here.
https://help.github.com/en/articles/configuring-a-workflow#using-the-checkout-action

The @master refers to the version of the action, not the branch you want to checkout. It seems that the correct way to specify a branch is as @TingluoHuang suggested.

@TingluoHuang
Copy link
Member

@peter-evans the doc is wrong, i will file issue for the doc problem.

@jugglinmike
Copy link
Author

That did the trick, thanks!

I'll leave this issue open in case you'd like to use it to track the documentation fix.

@TingluoHuang
Copy link
Member

close this since the doc get a little bit better. still waiting for more improvement

srini-hv pushed a commit to srini-hv/checkout that referenced this issue May 19, 2021
srini-hv pushed a commit to srini-hv/checkout that referenced this issue May 20, 2021
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

3 participants