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

Deploy on master and tags #7780

Closed
ghost opened this issue May 18, 2017 · 11 comments
Closed

Deploy on master and tags #7780

ghost opened this issue May 18, 2017 · 11 comments

Comments

@ghost
Copy link

ghost commented May 18, 2017

I'm trying to deploy on master and all tags.
As script as deploy provider I managed to do so using a condition on the on clause as following:

deploy:
  provider: script
  script: .ci/travis/deploy
  skip_cleanup: true
  on:
    condition: $TRAVIS_BRANCH == "master" || -n $TRAVIS_TAG

I'd expect the same using s3, but it seems like that it not the case.
I got Skipping a deployment with the s3 provider because this branch is not permitted.

deploy:
  provider: s3
  access_key_id: [secret]
  secret_access_key:
    secure: [secret]
  bucket: [secret]
  acl: public_read
  region: eu-west-2
  skip_cleanup: true
  local-dir: dist
  on:
    condition: $TRAVIS_BRANCH == "master" || -n $TRAVIS_TAG

Bug or wrong approch?

@BanzaiMan
Copy link
Contributor

Do you have a build log URL that shows the problem you are describing here?

@ghost
Copy link
Author

ghost commented May 18, 2017

@BanzaiMan
Copy link
Contributor

The distinction is not that of the deployment provider (S3 vs script), but, rather, that of the branch vs tag. In https://travis-ci.org/kiitoscpp/toolchain/jobs/233502168#L1884, you see that the S3 provider was invoked on a tag build and the file uploaded successfully.

This is a case where $TRAVIS_BRANCH is set to the tag name (i.e., v0.0.1 in https://travis-ci.org/kiitoscpp/toolchain/jobs/233510388), and therefore the custom condition is not met. (So, basically, this is a different manifestation of #4745.) There is an internal ticket to look at this issue.

For your use case, however, can be resolved right now by setting up two almost identical deployment providers which differ in just the condition; one should test branch, and the other tag.

deploy:
  - provider: s3
    access_key_id: [secret]
    secret_access_key:
      secure: [secret]
    bucket: [secret]
    acl: public_read
    region: eu-west-2
    skip_cleanup: true
    local-dir: dist
    on:
      branch: "master"
  - provider: s3
    access_key_id: [secret]
    secret_access_key:
      secure: [secret]
    bucket: [secret]
    acl: public_read
    region: eu-west-2
    skip_cleanup: true
    local-dir: dist
    on:
      tags: true

@ghost
Copy link
Author

ghost commented May 18, 2017

Thanks for the quick solution!
Anyway I still do not grasp it since in the condition is an or stmt and it should be evaluated as true in any case.

Hypothetically, if I define:

deploy:
  provider: s3
  ...
  on:
    condition: true

will this deploy in all cases (all branches and tags)?

@BanzaiMan
Copy link
Contributor

Yes, that works, but if you want to deploy on all branches and tags, we have a special one: all_branches.

@ghost ghost closed this as completed May 18, 2017
@ghost
Copy link
Author

ghost commented May 18, 2017

I tested and using condition: true the deployment is skipped.
I think this can be labeled as 🐛

@ghost ghost reopened this May 18, 2017
@BanzaiMan
Copy link
Contributor

Please include the build log URL.

@BanzaiMan
Copy link
Contributor

I think I misled you with the previous comment.

deploy:
  on:
    condition: true

is always true, to it is basically a no-op. This means that the deployment will trigger under the default condition, which is "only on the master branch". It will thus skip on https://travis-ci.org/kiitoscpp/toolchain/jobs/233717284 (a tag build).

@BanzaiMan
Copy link
Contributor

I don't think there is any more to do here. I'm closing this.

@ghost
Copy link
Author

ghost commented May 25, 2017

The best way in my opinion is to handle the deployment using script and all_branches: true
so you have freedom to do conditional checking inside the script itself.
Thanks for the help 💯

fregante added a commit to refined-github/refined-github that referenced this issue Oct 14, 2017
danderson added a commit to metallb/metallb that referenced this issue Dec 4, 2017
Annoyingly, because of travis-ci/travis-ci#7780, that means duplicating
the deployment section and just changing the condition :(.
shuhaowu added a commit to shuhaowu/ghostferry that referenced this issue May 16, 2018
bfirsh added a commit to arxiv-vanity/engrafo that referenced this issue Aug 17, 2018
mybluprint pushed a commit to mybluprint/refined-github that referenced this issue Sep 26, 2018
@michaelmior
Copy link

@BanzaiMan The whole point of condition: true is that the deploy should always happen. Are you meaning to say that Travis checks for this and ignores it?

Totktonada added a commit to tarantool/tarantool that referenced this issue Jun 14, 2019
The problem was that a tagged revision is not deployed, so after a
release we did an empty commit to trigger deployment. Now it is worked
around by adding extra deployment rules that deploys tagged revisions.
The workaround was suggested by Hiro Asari in [1].

[1]: travis-ci/travis-ci#7780 (comment)

Fixes #3745.
kyukhin pushed a commit to tarantool/tarantool that referenced this issue Jul 26, 2019
The problem was that a tagged revision is not deployed, so after a
release we did an empty commit to trigger deployment. Now it is worked
around by adding extra deployment rules that deploys tagged revisions.
The workaround was suggested by Hiro Asari in [1].

[1]: travis-ci/travis-ci#7780 (comment)

Fixes #3745.
Totktonada added a commit to tarantool/tarantool that referenced this issue Jul 26, 2019
The problem was that a tagged revision is not deployed, so after a
release we did an empty commit to trigger deployment. Now it is worked
around by adding extra deployment rules that deploys tagged revisions.
The workaround was suggested by Hiro Asari in [1].

[1]: travis-ci/travis-ci#7780 (comment)

Fixes #3745.

(cherry picked from commit 2fe7036)
Totktonada added a commit to tarantool/tarantool that referenced this issue Jul 26, 2019
The problem was that a tagged revision is not deployed, so after a
release we did an empty commit to trigger deployment. Now it is worked
around by adding extra deployment rules that deploys tagged revisions.
The workaround was suggested by Hiro Asari in [1].

[1]: travis-ci/travis-ci#7780 (comment)

Fixes #3745.

(cherry picked from commit 2fe7036)
edmorley added a commit to heroku/base-images that referenced this issue Apr 27, 2020
Before images were published to the nightly/date-versioned tags for
feature branches, and not just master/tags. This makes CI take longer,
creates more Docker repo churn, and means consumers of the nightly tags
could end up with unexpected changes from feature branches.

If testing of feature branches is required, images can be easily built
locally, or tags can be manually pushed.

The `TRAVIS_BRANCH` env var is being used inside the condition along with
`all_branches: true`, since for tags Travis overwrites the branch with
the tag name, meaning `branches: master` would exclude tags too. See:
travis-ci/travis-ci#7780

Refs W-7496420.
edmorley added a commit to heroku/base-images that referenced this issue Apr 27, 2020
Before images were published to the nightly/date-versioned tags for
feature branches, and not just master/tags. This makes CI take longer,
creates more Docker repo churn, and means consumers of the nightly tags
could end up with unexpected changes from feature branches.

If testing of feature branches is required, images can be easily built
locally, or tags can be manually pushed.

The `TRAVIS_BRANCH` env var is being used inside the condition along with
`all_branches: true`, since for tags Travis overwrites the branch with
the tag name, meaning `branches: master` would exclude tags too. See:
travis-ci/travis-ci#7780

Refs W-7496420.
Totktonada added a commit to tarantool/smtp that referenced this issue Jul 10, 2020
Totktonada added a commit to tarantool/smtp that referenced this issue Jul 10, 2020
Totktonada added a commit to tarantool/smtp that referenced this issue Jul 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants