forked from microsoft/ApplicationInsights-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreusable-create-docs-pull-request.yml
More file actions
86 lines (75 loc) · 3.58 KB
/
reusable-create-docs-pull-request.yml
File metadata and controls
86 lines (75 loc) · 3.58 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Reusable - Create docs pull request
on:
workflow_call:
inputs:
version:
type: string
required: true
secrets:
AARON_MAXWELL_TOKEN:
required: true
# to help with partial release build failures
workflow_dispatch:
inputs:
version:
description: "Version"
required: true
jobs:
create-docs-pull-request:
runs-on: ubuntu-latest
steps:
- name: Repo sync
# this step avoids having to do a deep fetch of the very large upstream repo
# (cannot use "git fetch --depth 1 upstream main" because that leads to an error when
# pushing below to the origin repo: "shallow update not allowed")
env:
VERSION: ${{ inputs.version }}
# this is the personal access token used for "gh repo sync" below
GH_TOKEN: ${{ secrets.AARON_MAXWELL_TOKEN }}
run: |
gh repo sync AaronMaxwell/azure-monitor-docs-pr \
--source MicrosoftDocs/azure-monitor-docs-pr
- uses: actions/checkout@v4
with:
repository: AaronMaxwell/azure-monitor-docs-pr
# this is the personal access token used for "git push" below
token: ${{ secrets.AARON_MAXWELL_TOKEN }}
- name: Update version in docs
env:
VERSION: ${{ inputs.version }}
run: |
date=$(TZ=America/Los_Angeles date "+%m/%d/%Y")
files=$(grep -rl applicationinsights-agent-[0-9.]*.jar articles/azure-monitor/app \
| grep -v deprecated-java-2x.md)
echo "$files" | xargs sed -Ei "s/applicationinsights-agent-[0-9.]+.jar/applicationinsights-agent-${VERSION}.jar/g"
echo "$files" | xargs sed -Ei "s|microsoft/ApplicationInsights-Java/releases/download/[0-9.]*/|microsoft/ApplicationInsights-Java/releases/download/${VERSION}/|g"
echo "$files" | xargs sed -Ei "/<artifactId>applicationinsights-.*<\/artifactId>/{n;s|<version>.*</version>|<version>${VERSION}</version>|;}"
echo "$files" | xargs sed -Ei "s|^ms.date: .*|ms.date: $date|"
- name: Create pull request against azure-docs-pr
env:
VERSION: ${{ inputs.version }}
# this is the personal access token used for "gh pr create" below
GH_TOKEN: ${{ secrets.AARON_MAXWELL_TOKEN }}
run: |
message="Update the applicationinsights-java version to $VERSION"
body="Update the applicationinsights-java version to \`$VERSION\`.
cc @AaronMaxwell @heyams @jeanbisutti @mattmccleary @trask
"
branch="update-applicationinsights-java-to-${VERSION}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b $branch
git commit -a -m "$message"
git push --set-upstream origin $branch
# gh pr create doesn't have a way to explicitly specify different head and base
# repositories currently, but it will implicitly pick up the head from a different
# repository if you set up a tracking branch
echo ========================================
echo To create PR, go to
echo https://github.com/MicrosoftDocs/azure-monitor-docs-pr/compare/main...AaronMaxwell:azure-docs-pr:${branch}?expand=1
echo ========================================
# TODO (trask) create PR automatically
# gh pr create --title "$message" \
# --body "$body" \
# --repo MicrosoftDocs/azure-monitor-docs-pr \
# --base main