Enable local deployments in Pull Requests

James Skimming's Avatar

James Skimming

26 Feb, 2015 10:58 PM

I've just been setting up local deployment to execute our suite of integration tests as part of the build.

I've now got it all working, but I've found that the deployments don't execute on forked pull requests.

I appreciate this is by design, but I wonder if it could be enabled similar to the "Enable secure variables in Pull Requests", something like "Enable local deployments in Pull Requests"?

We deploy both a website and a SSDT Package to create a databse as described here, so would require al types of local deploy to be enabled.

Do you think this is a worthwhile feature?

  1. Support Staff 1 Posted by Feodor Fitsner on 26 Feb, 2015 11:09 PM

    Feodor Fitsner's Avatar

    Would it work if we add "Enable all deployments in Pull Requests" for private projects?

  2. Support Staff 2 Posted by Feodor Fitsner on 27 Feb, 2015 05:18 AM

    Feodor Fitsner's Avatar

    OK, deployed an update with Enable deployments in Pull Requests project option for private GitHub projects.

  3. 3 Posted by James Skimming on 27 Feb, 2015 08:18 AM

    James Skimming's Avatar

    Thanks for the quick turnaround, I've tried it and it's working, but not quite as I'd expect.

    We have three deployments, expressed like this in the yml

    deploy:
    
      # Local databse for testing
      - provider: SqlDatabase
        artifact: TheDB.dacpac
        connection_string: 'Server=(local)\SQL2014;Database=TheDB;User ID=sa;Password=Password12!'
    
      # Local deployment for testing
      - provider: Local
        artifact: WebApp
        WebApp.deploy_website: true
        WebApp.site_name: Default Web Site
        WebApp.Portal.remove_files: true
    
      # QA deployment.
      - provider: Environment
        name: WebApp-QA
        on:
          branch: master
    

    The last environment is the QA environment (an Azure WebSite) that we only want to deploy when pull requests are accepted and merged. Since I've specified it only deploys on the master branch, I don't expect it to be deployed on PRs that have not been merged to master.

    I suspect it's related, but I've always found it confusing that PR builds show the destination branch as the branch.

    This is why I named the request "Enable local deployments in Pull Requests", I've no problem with it being all, as long as the branch restriction on deployments prevents PRs from deploying before they have been merged.

  4. Support Staff 4 Posted by Feodor Fitsner on 27 Feb, 2015 05:20 PM

    Feodor Fitsner's Avatar

    Yeah, I got it. But if it was just "Local" deployment provider it would be easier, but you also mentioned "SqlDatabase" where there is no way to detect whether you are targeting local SQL Server or Azure SQL or something else :)

    To prevent deploying to QA environment during pull request builds you could just use conditional variable. Basically, you can tell that provider deploy only if it's not PR. To do that define new environment variable with PowerShell like that:

    init:
      - ps: if(-not $env:APPVEYOR_PULL_REQUEST_NUMBER) { $env:is_not_pr = "true"; }
    

    then add this condition to deployment provider:

      # QA deployment.
      - provider: Environment
        name: WebApp-QA
        on:
          branch: master
          is_not_pr: true
    
  5. 5 Posted by James Skimming on 27 Feb, 2015 06:01 PM

    James Skimming's Avatar

    Great! That's working exactly as we need, we now have this in the build output

    Skip "Environment" deployment as environment variable has not matched ("is_not_pr" is "", should be "true")
    

    I really appreciate your help on this :-)

  6. James Skimming closed this discussion on 27 Feb, 2015 06:02 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac