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

Move image pushing into CircleCI #945

Merged
merged 1 commit into from
Oct 9, 2019
Merged

Move image pushing into CircleCI #945

merged 1 commit into from
Oct 9, 2019

Conversation

johnSchnake
Copy link
Contributor

What this PR does / why we need it:

  • Moves/updates the travis deploy script to work on circleCI.
  • Added DOCKERHUB_TOKEN via web UI to circleCI
  • runs publishing of images on master branch and on tags like v.*
  • minor change to naming to clarify job purposes

Which issue(s) this PR fixes
Ref: #926

Special notes for your reviewer:
I tried to use circleCI on my own repo to show this behavior to some extent. You can see here: https://circleci.com/workflow-run/9fdeb6cc-04ae-4e11-9173-bc2f06c14f40 that the publishing waits for the tests to pass. In addition, you can see https://circleci.com/workflow-run/9a9a49a3-5279-40ab-8638-9803a92063e1 doesn't show that the publishing would have occurred at all since it wasn't on the master branch.

Release note:

NONE

@johnSchnake johnSchnake requested a review from zubron October 9, 2019 17:49
 - Moves/updates the travis deploy script to work on circleCI.
 - Added DOCKERHUB_TOKEN via web UI to circleCI
 - runs publishing of images on master branch and on tags like v.*
 - minor change to naming to clarify job purposes

Ref: #926
Signed-off-by: John Schnake <[email protected]>
@codecov-io
Copy link

codecov-io commented Oct 9, 2019

Codecov Report

Merging #945 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #945   +/-   ##
=======================================
  Coverage   47.78%   47.78%           
=======================================
  Files          76       76           
  Lines        5226     5226           
=======================================
  Hits         2497     2497           
  Misses       2573     2573           
  Partials      156      156

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 03e44e6...b4a5edb. Read the comment docs.

- build_and_test
filters:
branches:
only: master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was reading about the filters earlier and came across this post: https://discuss.circleci.com/t/dont-run-deploy-workflow-step-for-forked-pr/23606
It suggests that a PR from the master branch of a fork would pass this filter. We might want to consider expanding the check in the publish script to check for one of the environment variables that are only set for forked PRs: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question.

So you're right on the approach (using env vars) and we do this though by checking the CIRCLE_BRANCH. For pull requests it is pull/945 or whatnot.

However, as I was typing my response I realized that for the tagged portion of the bash script we could hit a problem. E.g. If I make a PR that includes a tag on my commit I may be able to trigger that part of the build.

We can make this check a bit more verbose by checking for another env var value about the PR, but we should acknowledge that a malicious user could still manipulate the scripts/env vars to trigger these. I dont know if we can prevent that.

Copy link
Contributor

@zubron zubron Oct 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked the CIRCLE_BRANCH in a test PR and you're right, it sets the branch correctly to be a pull request branch:

#!/bin/bash -eo pipefail
echo $CIRCLE_BRANCH
echo $CIRCLE_PR_NUMBER
echo $CIRCLE_PR_REPONAME
echo $CIRCLE_PR_USERNAME
pull/946
946
sonobuoy
zubron

My concern was that CIRCLE_BRANCH would be set to the source branch, which could be master.

I'm not sure if there is anything that we can do to prevent malicious PRs. But, given that we've prevented the secrets being passed to forked PRs, they could bypass the checks but the steps shouldn't work because the secrets aren't available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, excellent point. The config settings in the UI prevent image pushing from ever actually occurring.

@johnSchnake johnSchnake merged commit ff5326e into vmware-tanzu:master Oct 9, 2019
@johnSchnake johnSchnake deleted the circleCIDockerPush branch October 9, 2019 18: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

Successfully merging this pull request may close these issues.

3 participants