-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into vidbala/t3workload
- Loading branch information
Showing
14 changed files
with
4,005 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
# disable CI per: | ||
# https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/github?view=azure-devops&tabs=yaml#disabling-the-ci-trigger | ||
trigger: none | ||
|
||
pr: | ||
branches: | ||
include: | ||
- main | ||
|
||
pool: | ||
vmImage: ubuntu-latest | ||
|
||
jobs: | ||
- job: shouldGenerateSbom | ||
displayName: 'Determine if SBOM needs to be generated' | ||
steps: | ||
- checkout: self | ||
|
||
- bash: | | ||
only_manifest_files=( | ||
_manifest/manifest.json | ||
_manifest/manifest.json.sha256 | ||
_manifest/spdx_2.2/manifest.spdx.json | ||
_manifest/spdx_2.2/manifest.spdx.json.sha256 | ||
) | ||
the_last_diff=( $(git log -1 --no-merges --name-only --pretty="") ) | ||
echo "only manifest files:" | ||
echo ${only_manifest_files[*]} | ||
echo "" | ||
echo "the last git diff:" | ||
echo ${the_last_diff[*]} | ||
echo "" | ||
BUILD_SBOM=true | ||
if [[ "${the_last_diff[*]}" == "${only_manifest_files[*]}" ]]; then | ||
BUILD_SBOM=false | ||
echo "These changes are just the manifest files." | ||
fi | ||
echo "##vso[task.setvariable variable=BUILD_SBOM;isOutput=true]$BUILD_SBOM" | ||
echo "BUILD_SBOM is $BUILD_SBOM" | ||
name: determineSbom | ||
displayName: 'Determine if SBOM needs to be built' | ||
- job: generateSbom | ||
dependsOn: shouldGenerateSbom | ||
condition: eq(dependencies.shouldGenerateSbom.outputs['determineSbom.BUILD_SBOM'], 'true') | ||
displayName: 'Generate SBOM' | ||
steps: | ||
- checkout: self | ||
persistCredentials: true | ||
|
||
- bash: | | ||
if [[ "$(Build.Reason)" == "Manual" ]]; then | ||
SOURCE_BRANCH=$(Build.SourceBranch) | ||
elif [[ "$(Build.Reason)" == "PullRequest" ]]; then | ||
SOURCE_BRANCH=$(System.PullRequest.SourceBranch) | ||
else | ||
echo "This pipeline can only be invoked manually or on PR." | ||
echo "Exiting." | ||
exit 1 | ||
fi | ||
echo "The source branch is $SOURCE_BRANCH" | ||
echo "##vso[task.setvariable variable=SOURCE_BRANCH;]$SOURCE_BRANCH" | ||
displayName: 'Determine the branch name' | ||
- bash: | | ||
cd $(Build.SourcesDirectory) | ||
rm -rf _manifest | ||
displayName: 'Remove previous _manifest contents' | ||
- bash: | | ||
cd $(Build.SourcesDirectory) | ||
cp -r .git $(Build.ArtifactStagingDirectory) | ||
rm -rf .git | ||
displayName: 'Temporarily move .git so it is not a part of the SBOM' | ||
- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0 | ||
displayName: 'Generate SBOM' | ||
inputs: | ||
BuildComponentPath: '$(Build.SourcesDirectory)' | ||
BuildDropPath: '$(Build.SourcesDirectory)' | ||
PackageName: 'Mission LZ' | ||
PackageVersion: '$(Build.BuildNumber)' | ||
Verbosity: Verbose | ||
|
||
- bash: | | ||
cd $(Build.SourcesDirectory) | ||
cat _manifest/manifest.json | jq . > temp.json \ | ||
&& mv temp.json _manifest/manifest.json \ | ||
&& rm -f temp.json | ||
cat _manifest/spdx_2.2/manifest.spdx.json | jq . > temp.json \ | ||
&& mv temp.json _manifest/spdx_2.2/manifest.spdx.json \ | ||
&& rm -f temp.json | ||
displayName: 'Pretty Print SBOM' | ||
- bash: | | ||
cd $(Build.ArtifactStagingDirectory) | ||
cp -r .git $(Build.SourcesDirectory) | ||
rm -rf .git | ||
displayName: 'Restore .git so we can commit back to the source branch' | ||
- bash: | | ||
git config --global user.email "$BUILD_REQUESTEDFOREMAIL" | ||
git config --global user.name "$BUILD_REQUESTEDFOR" | ||
git checkout -t origin $(SOURCE_BRANCH) | ||
git add '_manifest/*' | ||
git status | ||
git commit -m "Update Software Bill of Materials (SBOM)" | ||
git push --set-upstream origin HEAD:$(SOURCE_BRANCH) | ||
displayName: 'Commit SBOM changes back to source branch' | ||
- task: PublishBuildArtifacts@1 | ||
displayName: 'Publish SBOM as Build Artifact' | ||
inputs: | ||
PathtoPublish: '$(Build.SourcesDirectory)/_manifest' | ||
ArtifactName: 'drop' | ||
publishLocation: 'Container' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,14 @@ | |
# Licensed under the MIT License. | ||
|
||
name: validate-build-bicep | ||
on: | ||
on: | ||
pull_request: | ||
branches: [main] | ||
paths: | ||
paths: | ||
- 'src/bicep/**' | ||
- '!src/bicep/**.md' | ||
env: | ||
BICEP_VERSION: 'v0.4.1272' | ||
jobs: | ||
validate-build: | ||
runs-on: ubuntu-latest | ||
|
@@ -18,6 +20,8 @@ jobs: | |
- run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
az bicep install --version "$BICEP_VERSION" | ||
az bicep version | ||
az bicep build --file src/bicep/mlz.bicep --outfile src/bicep/mlz.json | ||
if [[ $(git status --porcelain) ]]; then | ||
git add src/bicep/mlz.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.