@@ -1768,6 +1768,75 @@ List<string> GetTracerStagesThatWillNotRun(string[] gitChanges)
1768
1768
}
1769
1769
} ) ;
1770
1770
1771
+ Target GenerateUpdateGitHubPipelineStep
1772
+ => _ => _
1773
+ . Unlisted ( )
1774
+ . Executes ( ( ) =>
1775
+ {
1776
+ var tracerConfig = PipelineParser . GetPipelineDefinition ( RootDirectory ) ;
1777
+
1778
+ var dependsOnStages = tracerConfig
1779
+ . Stages
1780
+ . Where ( x => ! string . IsNullOrEmpty ( x . Stage ) )
1781
+ . Select ( x => $ " - { x . Stage } ") ;
1782
+ var dependsOn = string . Join ( Environment . NewLine , dependsOnStages ) ;
1783
+
1784
+ var conditionStages = tracerConfig
1785
+ . Stages
1786
+ . Where ( x => ! string . IsNullOrEmpty ( x . Stage ) )
1787
+ . Select ( x => $ " in(dependencies.{ x . Stage } .result, 'Succeeded','SucceededWithIssues','Skipped')") ;
1788
+ var conditions = string . Join ( $ ",{ Environment . NewLine } ", conditionStages ) ;
1789
+
1790
+ var template =
1791
+ $ """
1792
+ # This file is auto-generated by Build.VariableGenerations.GenerateUpdateGitHubPipelineStep
1793
+ stages:
1794
+ - stage: azure_pipeline_succeeded
1795
+ dependsOn:
1796
+ { dependsOn }
1797
+ condition: |
1798
+ and(
1799
+ { conditions } )
1800
+ jobs:
1801
+ - job: report_success
1802
+ timeoutInMinutes: 60 #default value
1803
+ pool:
1804
+ name: azure-managed-linux-tasks
1805
+ steps:
1806
+ - checkout: none
1807
+ - template: update-github-status.yml
1808
+ parameters:
1809
+ checkName: 'azure_pipeline_complete'
1810
+ status: 'success'
1811
+ description: 'Pipeline succeeded'
1812
+ - stage: azure_pipeline_failed
1813
+ dependsOn:
1814
+ { dependsOn }
1815
+ condition: |
1816
+ not(and(
1817
+ { conditions } ))
1818
+ jobs:
1819
+ - job: report_failure
1820
+ timeoutInMinutes: 60 #default value
1821
+ pool:
1822
+ name: azure-managed-linux-tasks
1823
+ steps:
1824
+ - checkout: none
1825
+ - template: update-github-status.yml
1826
+ parameters:
1827
+ checkName: 'azure_pipeline_complete'
1828
+ status: 'failure'
1829
+ description: 'One or more stages failed. See associated failed Azure DevOps jobs'
1830
+
1831
+ """ ;
1832
+
1833
+ Logger . Information ( "Regenerated azure pipeline template {Template}" , template ) ;
1834
+
1835
+ var templatePath = RootDirectory / ".azure-pipelines" / "steps" / "update-github-pipeline-status.yml" ;
1836
+ File . WriteAllText ( templatePath , template ) ;
1837
+ Logger . Information ( "Update template at {Path}" , templatePath ) ;
1838
+ } ) ;
1839
+
1771
1840
static bool IsGitBaseBranch ( string baseBranch )
1772
1841
{
1773
1842
// *****
0 commit comments