Skip to content

Commit 7bf50a8

Browse files
authored
Create doc PR on release (#2687)
1 parent e69bbcc commit 7bf50a8

File tree

4 files changed

+160
-39
lines changed

4 files changed

+160
-39
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
jobs:
66
release:
77
runs-on: ubuntu-latest
8+
outputs:
9+
version: ${{ steps.create-github-release.outputs.version }}
810
steps:
911
- uses: actions/checkout@v3
1012

@@ -33,12 +35,12 @@ jobs:
3335
sleep 60
3436
done
3537
36-
- name: Create GitHub release
38+
- id: create-github-release
39+
name: Create GitHub release
3740
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3942
run: |
4043
if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
41-
then
4244
opt_ga=" (GA)"
4345
else
4446
opt_prerelease="--prerelease"
@@ -52,41 +54,20 @@ jobs:
5254
$VERSION \
5355
applicationinsights-agent-$VERSION.jar
5456
55-
bump-version:
56-
runs-on: ubuntu-latest
57+
echo "::set-output name=version::$VERSION"
58+
59+
create-docs-pull-request:
5760
needs:
5861
- release
59-
steps:
60-
- uses: actions/checkout@v3
62+
uses: ./.github/workflows/reusable-create-docs-pull-request.yml
63+
with:
64+
version: ${{ needs.release.outputs.version }}
65+
secrets:
66+
AARON_MAXWELL_TOKEN: ${{ secrets.AARON_MAXWELL_TOKEN }}
6167

62-
- name: Set environment variables
63-
run: |
64-
version=$(.github/scripts/get-version.sh)
65-
if [[ $version =~ ^([0-9]+\.[0-9]+)\.([0-9]+)$ ]]; then
66-
major_minor="${BASH_REMATCH[1]}"
67-
patch="${BASH_REMATCH[2]}"
68-
else
69-
echo "unexpected version: $version"
70-
exit 1
71-
fi
72-
echo "NEXT_VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV
73-
74-
- name: Update version
75-
run: .github/scripts/update-version.sh $NEXT_VERSION
76-
77-
- name: Create pull request against main
78-
env:
79-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80-
run: |
81-
message="Update version to $NEXT_VERSION"
82-
body="Update version to \`$NEXT_VERSION\`."
83-
branch="automation/update-version-to-${NEXT_VERSION}"
84-
85-
git config user.name "github-actions[bot]"
86-
git config user.email "github-actions[bot]@users.noreply.github.com"
87-
88-
git checkout -b "$branch"
89-
git commit -a -m "$message"
90-
git push --set-upstream origin HEAD:$branch
91-
gh pr create --title "$message" \
92-
--body "$body"
68+
create-version-bump-pull-request:
69+
needs:
70+
- release
71+
uses: ./.github/workflows/reusable-create-version-bump-pull-request.yml
72+
with:
73+
version: ${{ needs.release.outputs.version }}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Reusable - Create docs pull request
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
type: string
8+
required: true
9+
secrets:
10+
AARON_MAXWELL_TOKEN:
11+
required: true
12+
# to help with partial release build failures
13+
workflow_dispatch:
14+
inputs:
15+
version:
16+
description: "Version"
17+
required: true
18+
19+
jobs:
20+
create-docs-pull-request:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Repo sync
24+
# this step avoids having to do a deep fetch of the very large upstream repo
25+
# (cannot use "git fetch --depth 1 upstream main" because that leads to an error when
26+
# pushing below to the origin repo: "shallow update not allowed")
27+
env:
28+
VERSION: ${{ inputs.version }}
29+
# this is the personal access token used for "gh repo sync" below
30+
GH_TOKEN: ${{ secrets.AARON_MAXWELL_TOKEN }}
31+
run: |
32+
gh repo sync AaronMaxwell/azure-docs-pr \
33+
--source MicrosoftDocs/azure-docs-pr
34+
35+
- uses: actions/checkout@v3
36+
with:
37+
repository: AaronMaxwell/azure-docs-pr
38+
# this is the personal access token used for "git push" below
39+
token: ${{ secrets.AARON_MAXWELL_TOKEN }}
40+
41+
- name: Update version in docs
42+
env:
43+
VERSION: ${{ inputs.version }}
44+
run: |
45+
date=$(date "+%m/%d/%Y")
46+
files=$(grep -rl applicationinsights-agent-[0-9.]*.jar articles/azure-monitor/app \
47+
| grep -v java-2x-agent.md)
48+
echo "$files" | xargs sed -Ei "s/applicationinsights-agent-[0-9.]+.jar/applicationinsights-agent-${VERSION}.jar/g"
49+
echo "$files" | xargs sed -Ei "s|microsoft/ApplicationInsights-Java/releases/download/[0-9.]*/|microsoft/ApplicationInsights-Java/releases/download/${VERSION}/|g"
50+
echo "$files" | xargs sed -Ei "s|^ms.date: .*|ms.date: $date|"
51+
52+
- name: Create pull request against azure-docs-pr
53+
env:
54+
VERSION: ${{ inputs.version }}
55+
# this is the personal access token used for "gh pr create" below
56+
GH_TOKEN: ${{ secrets.AARON_MAXWELL_TOKEN }}
57+
run: |
58+
message="Update the applicationinsights-java version to $VERSION"
59+
body="Update the applicationinsights-java version to \`$VERSION\`.
60+
61+
cc @AaronMaxwell @heyams @jeanbisutti @mattmccleary @trask
62+
"
63+
branch="update-applicationinsights-java-to-${VERSION}"
64+
65+
git config user.name "github-actions[bot]"
66+
git config user.email "github-actions[bot]@users.noreply.github.com"
67+
68+
git checkout -b $branch
69+
git commit -a -m "$message"
70+
git push --set-upstream origin $branch
71+
72+
# gh pr create doesn't have a way to explicitly specify different head and base
73+
# repositories currently, but it will implicitly pick up the head from a different
74+
# repository if you set up a tracking branch
75+
76+
echo ========================================
77+
echo To create PR, go to
78+
echo https://github.com/MicrosoftDocs/azure-docs-pr/compare/main...AaronMaxwell:azure-docs-pr:${branch}?expand=1
79+
echo ========================================
80+
81+
# TODO (trask) create PR automatically
82+
# gh pr create --title "$message" \
83+
# --body "$body" \
84+
# --repo MicrosoftDocs/azure-docs-pr \
85+
# --base main
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Reusable - Create version bump pull request
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
type: string
8+
required: true
9+
# to help with partial release build failures
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: "Version"
14+
required: true
15+
16+
jobs:
17+
bump-version:
18+
runs-on: ubuntu-latest
19+
needs:
20+
- release
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- name: Set environment variables
25+
env:
26+
VERSION: ${{ inputs.version }}
27+
run: |
28+
if [[ $VERSION =~ ^([0-9]+\.[0-9]+)\.([0-9]+)$ ]]; then
29+
major_minor="${BASH_REMATCH[1]}"
30+
patch="${BASH_REMATCH[2]}"
31+
else
32+
echo "unexpected version: $VERSION"
33+
exit 1
34+
fi
35+
echo "NEXT_VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV
36+
37+
- name: Update version
38+
run: .github/scripts/update-version.sh $NEXT_VERSION
39+
40+
- name: Create pull request against main
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
message="Update version to $NEXT_VERSION"
45+
body="Update version to \`$NEXT_VERSION\`."
46+
branch="automation/update-version-to-${NEXT_VERSION}"
47+
48+
git config user.name "github-actions[bot]"
49+
git config user.email "github-actions[bot]@users.noreply.github.com"
50+
51+
git checkout -b "$branch"
52+
git commit -a -m "$message"
53+
git push --set-upstream origin HEAD:$branch
54+
gh pr create --title "$message" \
55+
--body "$body"

.github/workflows/reusable-open-issue-on-failure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111

1212
- name: Open issue
1313
env:
14-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1515
run: |
1616
gh issue create --title "$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER failed" \
1717
--body "See [$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)."

0 commit comments

Comments
 (0)