Yml config for building & deploying react app

五迷三道 提交于 2019-12-11 05:38:46

问题


I want to create a yml file to prevent my production code from deploying when a new commit is made to the repo.

I only want the production code to be built & deployed if a direct push is made to the master branch. My existing yml config builds & deploys my changes if I create a pull request - without actually merging. I want to stop this. I only want the 'building & deploying' part to be done after a pull request has been made and changes are actually pushed into master.

This is what my current .travis.yml file looks like:

language: node_js
node_js:
  - "8.12"
script: 
  - npm i
  - if [ "$TRAVIS_BRANCH" == "master" ]; then echo "Deploying to firebase";  - CI=false npm run build  fi
install:
  - if [ "$TRAVIS_BRANCH" == "master" ]; then npm i -g firebase-tools; fi
after_success:
  - if [ "$TRAVIS_BRANCH" == "master" ]; then firebase deploy --token "$FIREBASE_TOKEN"; fi 

I had a go at changing that to something more slick:

language: node_js
node_js:
  - "8.12"

stages: 
  - compile
  - test
  - name: deploy
    if: branch = master AND NOT (type = push OR type = pull_request OR fork = true)
env:
  - CI=false

jobs: 
  include: 
    - stage: compile 
      script: 
        - npm i

    - stage: test
      script: ""

    - stage: deploy
      install: npm i -g firebase-tools
      script: 
        - npm run build
    after_success:
        - firebase deploy --token "$FIREBASE_TOKEN"

but this isn't valid yml.

How can I set it so that it only deploys when the code has actually been merged into master (and only that). I still want to execute tests and stuff if pushes are made to other branches like develop etc.

来源:https://stackoverflow.com/questions/52909145/yml-config-for-building-deploying-react-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!