GitHub-Actions: Trigger on creation of Draft of GitHub-Release - github-api

To simplify the release of a new version, I want to use GitHub-Actions to build my project. This should be triggered by creating a release-draft.
Basically, the workflow should be as follows:
When a new release should be created, a draft is created (manually), containing the proper tag, name and body. When the draft is saved, the action should take over and build the project in its current state, then add the built file to the release draft and finally publish it.
I don't want it to trigger when the draft is published, as it is already available then, even before the action has finished building the real file that should be released.
I tried using all triggers of release with
on: # When to trigger this action
release: # trigger on all release-events
workflow_dispatch: # allow manual triggering
However, that doesn't seem to trigger when the draft is saved, only when it's being published.
Is there any way to trigger this workflow without publishing the release, but only by creating a draft?

Related

Only releases with status draft may be created on draft app. How do I tell Azure DevOps to mark a release as "draft"?

I have
developed a skeleton Android App in Android Studio
the Build pipeline in Azure DevOps
An Internal Testing track for this app on my Google Dev Console
Uploaded MANUALLY via the GUI of the Google Dev Console the signed .aab bundle produced
via Android Studio to the Internal Testing Track
The testers that had been set up for the track have been able to install the app on their devices and test it
The steps above work fine.
I then implemented the following
Created a Release Pipeline in Azure DevOps using the editor (not in YAML)
In this Release the Google Play Release Bundle plugin has been used (see pics
below) with its Track Property set to "Internal test" as per the available dropdown
value
Added a Deploy Stage following this Release (see pics below).
However, when the Release pipeline runs I get the error in the title (Only releases with status draft may be created on draft app.) that is also visible in the screenshots below.
I read the SO posts below
Only releases with status draft may be created on draft app
ERROR: Only releases with status draft may be created on draft app
and also articles/documentation like the following
Trigger Azure Pipelines with Postman and Parameters
Release pipelines - What is a draft Release
Releases - Create
How do I specify variables I want to edit when a release is created?
Publish to Google Play Store
I suspect that to remove the error I need to somehow create a release such that
isDraft = true;
that is a draft release that would not be rejected on deployment by the Azure Dev Console Internal Testing Track, but I am a bit at loss with it as I would have expected the Google Play Release Bundle plugin to take care of this detail for me but something apparently goes wrong or I do not clearly understand and I cannot figure out what it is or how to approach this problem in the best/simplest way.

How to create bug or Notification in only one task/Job when other task/Job failed in an Agent in devops in Release Pipe line

I have an pipeline which will have few task mentioned in the image. I'm creating a bug work item when a particular task failed which is working fine using logic app.
Now my problem is I don't want to add every time new task for bug creation after each deployment task mentioned in the image.
Is there any way I can create only one bug work item based on failure in any of the task in the pipeline. may be in the last or somewhere..?
Not sure why you had to go the Logic app route as there is an option to do this with Azure Pipelines itself out of the box.
Navigate to {your pipeline} > Options as shown below:
If the build pipeline fails, you can automatically create a work item to track getting the problem fixed. You can specify the work item type. You can also select if you want to assign the work item to the requestor. For example, if this is a CI build, and a team member checks in some code that breaks the build, then the work item is assigned to that person.
Additional Fields: You can also set the value of other work item fields. For example:
Field Value
------- -------
System.Title Build $(Build.BuildNumber) failed
System.Reason Build failure
Check Build Options for more details.
UPDATE:
Doing this for Release Pipelines is not supported as an out of the box feature as of today. However, there are extensions available in the Visual Studio marketplace that can be used as alternatives until it is supported.
Here are two such extensions:
Create Bug on Release failure
Create Work Item
Another idea with PowerShell tasks is discussed here.

What is the difference between Continuous deployment trigger and Pull request trigger?

Azure DevOps Release pipeline artifact settings has 2 options:
Continuous deployment trigger - Enabling the trigger will create a new release every time a new build is available.
Pull request trigger - Enabling this will create a release every time a selected artifact is available as part of a pull request workflow
I am trying to understand what is the difference between these options with respect to the highlighted parts and whether the build validation policy causes release to trigger with both options, if so then why do we have pull request trigger?
In my opinion, these two triggers have different working scope.
Assuming we set one CI build as release artifact, according to my test:
1.Continuous deployment trigger:
Whenever we have a new version of the Build, it triggers the release. It means that no matter the build pipeline is triggered by manual run, CI trigger or build validation in branch policy, the release is triggered when there's one newer build.
2.Pull request trigger:
It has a smaller scope, it will be trigger by the build pipeline which is trigger by build validation in branch policy.
(Which is triggered by PR, so if we create new PR=>It triggers PR build=>It triggers PR release)
Feel free to correct me if I misunderstand anything.
Update1:
Here's one pic about my two tests:
Release-8 is triggered by my manual running Build pipeline with only CD triggered enabled. And Release-7 is triggered by PR build with only PR triggered enabled. (I only enable the Pull Request for deployment in Stage 1)
Apart from working scope, these two triggers also have a little difference here. The Pull Request Deployment in stage for now is only for PR trigger in Artifact.
This explains that very well (taken from documentation):
Pull requests (PRs) provide an effective way to have code reviewed
before it is merged to the codebase. However, certain issues can be
tricky to find until the code is built and deployed to an environment.
Before the introduction of pull request release triggers, when a PR
was raised, you could trigger a build, but not a deployment. Pull
request triggers enable you to create pull request releases that
deploy your PR code or PR builds to detect deployment issues before
the code changes are merged. You can use pull request triggers with
code hosted on Azure Repos or GitHub.
New build basically means that your pipeline was executed.
Creating pull request trigger you need to define an artifact which will be later deployed. For this kind of trigger Azure Devops runs your pipeline and produce artifact according to your pipeline/build definition and later use this artifact for deployment.
Both trigger are similar, the difference is when your code will be deployed before or after being merged into main branch.
PR trigger is part of CI - applies when your merge your branch to master
CD trigger - applies only to the master branch

When the "pull request trigger" on the build artifact is disabled, Why is build due to a PR (build validation policy) triggering a release?

In my release pipeline I have configured build artifact. Enabled the 'continuous deployment trigger' (not added any branch filter) and disabled 'Pull request trigger'. Now when I raise PR, then the PR triggers a build (since I also have build validation configured in branch policy).
Once build completes, it triggers a release. Why does this happen when I have the "pull request trigger" disabled? Why is build due to a PR triggering a release when the "pull request trigger" on the build artifact is disabled?
The triggering of release prior to PR completion is prevented only when I add a branch filter to the "continuous deployment trigger".
Here I'll restore your scene and add some screenshots to illustrate it.
First we need to understand the definition of Continuous deployment triggers:
This instructs Azure Pipelines to create new releases automatically
when it detects new artifacts are available.
Because you set the pr build vaildation policy, when a pr is created, it will automatically trigger a pr build.
At this time, this pr build is equivalent to generating a new available artifact, which will automatically trigger the release.
This release is actually caused by Continuous deployment trigger, not because of Pull request trigger.
This the expected behavior, if you configured CD to any branch so after build is finished the release is started, no matter if the build is queued by Pull Request.
If you want to upload artifacts in part of the PR you should disable the CD trigger or use the artifacts filter.
Please read here and here the PR trigger docs.

Azure Pipelines DevOps Not Being Triggered by PR

I've been using Azure Pipelines for a while now and haven't changed my azure-pipelines.yml file here in 2 months. Previously, when there was a new PR, the pipeline would trigger and cause the environment to be built and the tests would be run.
Today, there was a new PR but I noticed that the pipeline was not being triggered. Then, to further test this, I forked, cloned, and branched the repository myself and created another new PR and, again, the pipeline was not triggered.
It's not clear to me where things are getting stuck and it's not clear how one would debug this. I've gone through this Azure DevOps documentation but it wasn't useful. I can manually trigger the pipeline to execute and test the master branch but I don't know how to manually trigger the same thing for a PR. Here's my Azure DevOps page for reference.
As normal, you do not need config pr in YAML script if there's no any special demand, we would do pull request trigger for all branches. But, it start broken from 03-13 21:02 (UTC), which caused by us, you do not do anything wrong.
The fix is preparing with our best.
As Alex said, this is the implicit trigger which YAML support only, if you do not configure pr in YAML explicitly.
To avoid such stuck later, except the method that Alex mentioned: add pr into YAML. You can also make use of UI configuration which performance is very stable until now.
Just go Pipeline definition page => Click on three dots of right corner => Select Trigger:
Then you will see Triggers tab which has Continues integration and Pull request validation display below. Open Pull request validation and enable Override the YAML pull request trigger from here:
Additional, Our team has noticed this broken issue, will update whether it is fixed here once we have any fixed release in progress.
Update 3/18/2020:
Fixed has released to all region. Every one can work github pr trigger as the document shows now.

Resources