forked from devcontainers/cli
-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
53 lines (51 loc) · 1.85 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
pool:
vmImage: "ubuntu-latest"
trigger:
branches:
include:
- 'main'
- 'release/*'
pr: none
steps:
- checkout: self
persistCredentials: true
- task: ComponentGovernanceComponentDetection@0
- task: notice@0
displayName: 'NOTICE File Generator'
inputs:
outputformat: 'text'
- task: DownloadPipelineArtifact@2
- script: |
PIPELINE_WORKSPACE="$(Pipeline.Workspace)"
if [ "$(sort "$PIPELINE_WORKSPACE/NOTICE.txt/NOTICE.txt" | tr -d '\015')" = "$(sort ThirdPartyNotices.txt | tr -d '\015')" ]
then
echo "3rd-party notices unchanged."
else
echo "3rd-party notices changed."
MESSAGE="Auto-update ThirdPartyNotices.txt"
if [ "$(git log -1 --pretty=%B | head -n 1)" = "$MESSAGE" ]
then
echo "Triggered by own commit, exiting."
exit 0
fi
git config --get 'http.https://github.com/devcontainers/cli.extraheader' | cut -d ' ' -f 3 | base64 -d | cut -d : -f 2 | gh auth login --with-token
SOURCE_BRANCH="$(echo "$(Build.SourceBranch)" | cut -d / -f 3-)"
echo "Source branch: $SOURCE_BRANCH"
PR_LIST="$(gh pr list --base "$SOURCE_BRANCH" --jq ".[] | select(.title == \"$MESSAGE\")" --json headRefName,title,url | cat)"
echo "$PR_LIST"
if [ ! -z "$PR_LIST" ]
then
echo "PR exists, exiting."
exit 0
fi
LOCAL_BRANCH="chrmarti/update-third-party-notices-$(date +%s)"
git checkout -b "$LOCAL_BRANCH"
cp "$PIPELINE_WORKSPACE/NOTICE.txt/NOTICE.txt" ThirdPartyNotices.txt
git status
git add ThirdPartyNotices.txt
git config --global user.email "[email protected]"
git config --global user.name "Christof Marti"
git commit -m "$MESSAGE"
git push -u origin "$LOCAL_BRANCH"
gh pr create --title "$MESSAGE" --body "Auto-generated PR to update ThirdPartyNotices.txt" --base "$SOURCE_BRANCH"
fi