Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Triggering a Release pipeline when adding git tag in Github

I want to automatically trigger a Azure Release pipeline upon adding a git tag in Github.

I tried to specify as branch on the Continuous Deployment trigger for the Artifact:

  • /refs/tags/*
  • *

but both options do not trigger a release upon creation of a git tag.

When I use * as trigger filter and push a commit to e.g. the master branch of my repo I am able to trigger the Release pipeline.

Am I missing something here, or is it a Azure DevOps limitation?

like image 784
Joost Avatar asked Dec 11 '18 20:12

Joost


People also ask

How do I tag a release in GitHub?

On GitHub.com, navigate to the main page of the repository. To the right of the list of files, click Releases. Click Draft a new release. Click Choose a tag, type a version number for your release, and press Enter.

How do you add a tag to a pipeline?

To add tags to a new pipeline, add the --tags option to your create-pipeline command. For example, the following option creates a pipeline with two tags, an environment tag with a value of production , and an owner tag with a value of sales . Javascript is disabled or is unavailable in your browser.

How do you trigger another pipeline?

To trigger a pipeline upon the completion of another pipeline, configure a pipeline resource trigger. The following example configures a pipeline resource trigger so that a pipeline named app-ci runs after any run of the security-lib-ci pipeline completes. This example has the following two pipelines.


1 Answers

One approach could be to use the Azure/pipelines GitHub Action to trigger the Azure Pipeline.

The actions to support this were announced in the Azure DevOps Sprint 161 release notes

An example is available on GitHub, the interesting bit is this:

 deploy-using-azure-pipelines:
    runs-on: ubuntu-latest
    steps:
    - name: 'Trigger an Azure Pipeline to deploy the app to PRODUCTION'
      uses: Azure/pipelines@releases/v1
      with:
        azure-devops-project-url: 'https://dev.azure.com/OrganizationName/ProjectName'
        azure-pipeline-name: 'WebApp_Azure_Prod' 
        azure-devops-token: '${{ secrets.AZURE_DEVOPS_TOKEN }}'

You would need to change the URL and create a secret named AZURE_DEVOPS_TOKEN in the GitHub project that has an Azure DevOps personal access token.

The trigger for your GitHub Action workflow could use something similar to the answers in Trigger Github Action only on new tags?

like image 76
David Gardiner Avatar answered Sep 21 '22 14:09

David Gardiner