reg-suit icon indicating copy to clipboard operation
reg-suit copied to clipboard

What's happen at TravisCI when PR from forked repo?

Open Quramy opened this issue 7 years ago • 1 comments

Hmmm, I think I'm in trouble detecting the previous and current git-hash....

The example job log is here. In this job, both previous(null) and current(1a95a49087dad68baec) hashes are incorrect.

The above job was triggered PR https://github.com/Quramy/rs-fork-pr-demo-repo/pull/2, which into origin/master from quramy-alt:master. Now, to detection base-hash, the CI script(.travis.yml) executes the following commands:

before_script:
  - git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
  - git fetch origin
  - git checkout $TRAVIS_BRANCH || git checkout -b $TRAVIS_BRANCH

The above workaround looked good for us only if PRs are limited in-house, but when the PR is derived from other(forked) repos, it does not make sense. It's because that the fetched origin doesn't have the forked repository. This command updates from not forked but source repository.

And more nastily, if the env value $TRAVIS_BRANCH is equal to "master" the checkout $TRAVIS_BRANCH exit with 0 successfully because the pointed branch is exists in both forked and source repos.

Quramy avatar Aug 06 '17 18:08 Quramy

I don't know better workarounds... For now, write attention about

  • Don't run reg-suit at CI jobs derived from "outer"(forked) repositories, because:
    • When using S3 plugin, it needs aws access secret. The value should not be accessed from visiter's job(They could append echo $AWS_ACCESS_SECRET onto .travis.yml)

Quramy avatar Aug 07 '17 11:08 Quramy