-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
160 additions
and
39 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
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,85 @@ | ||
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-docs-pr \ | ||
--source MicrosoftDocs/azure-docs-pr | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: AaronMaxwell/azure-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=$(date "+%m/%d/%Y") | ||
files=$(grep -rl applicationinsights-agent-[0-9.]*.jar articles/azure-monitor/app \ | ||
| grep -v java-2x-agent.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 "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-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-docs-pr \ | ||
# --base main |
55 changes: 55 additions & 0 deletions
55
.github/workflows/reusable-create-version-bump-pull-request.yml
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,55 @@ | ||
name: Reusable - Create version bump pull request | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
version: | ||
type: string | ||
required: true | ||
# to help with partial release build failures | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "Version" | ||
required: true | ||
|
||
jobs: | ||
bump-version: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- release | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set environment variables | ||
env: | ||
VERSION: ${{ inputs.version }} | ||
run: | | ||
if [[ $VERSION =~ ^([0-9]+\.[0-9]+)\.([0-9]+)$ ]]; then | ||
major_minor="${BASH_REMATCH[1]}" | ||
patch="${BASH_REMATCH[2]}" | ||
else | ||
echo "unexpected version: $VERSION" | ||
exit 1 | ||
fi | ||
echo "NEXT_VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV | ||
- name: Update version | ||
run: .github/scripts/update-version.sh $NEXT_VERSION | ||
|
||
- name: Create pull request against main | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
message="Update version to $NEXT_VERSION" | ||
body="Update version to \`$NEXT_VERSION\`." | ||
branch="automation/update-version-to-${NEXT_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 HEAD:$branch | ||
gh pr create --title "$message" \ | ||
--body "$body" |
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