Create collector-contrib pull request on release (#369)

* Create collector-contrib pull request on release

* Single bot
This commit is contained in:
Trask Stalnaker 2022-06-22 18:14:36 -07:00 committed by GitHub
parent bdfa232a04
commit 561ce29674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 93 additions and 1 deletions

View File

@ -54,6 +54,9 @@ jobs:
needs:
- build
- integration-test
outputs:
jmx-metrics-version: ${{ steps.create-github-release.outputs.jmx-metrics-version }}
jmx-metrics-sha256: ${{ steps.create-github-release.outputs.jmx-metrics-sha256 }}
steps:
- run: |
if [[ $GITHUB_REF_NAME != release/* ]]; then
@ -164,11 +167,13 @@ jobs:
.github/scripts/generate-release-contributors.sh v$PRIOR_VERSION >> /tmp/release-notes.txt
fi
- id: create-github-release
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cp jmx-metrics/build/libs/opentelemetry-jmx-metrics-$VERSION-alpha.jar opentelemetry-jmx-metrics.jar
jmx_metrics_version=$VERSION-alpha
cp jmx-metrics/build/libs/opentelemetry-jmx-metrics-$jmx_metrics_version.jar opentelemetry-jmx-metrics.jar
gh release create --target $GITHUB_REF_NAME \
--title "Version $VERSION" \
--notes-file /tmp/release-notes.txt \
@ -176,6 +181,9 @@ jobs:
v$VERSION \
opentelemetry-jmx-metrics.jar
echo "::set-output name=jmx-metrics-version::$jmx_metrics_version"
echo "::set-output name=jmx-metrics-sha256::$(sha256sum opentelemetry-jmx-metrics.jar)"
- uses: actions/checkout@v3
with:
# the step below is creating a pull request against main
@ -252,3 +260,12 @@ jobs:
--body "$body" \
--head $branch \
--base main
create-collector-contrib-pull-request:
needs: release
uses: ./.github/workflows/reusable-create-collector-contrib-pull-request.yml
with:
jmx-metrics-version: ${{ needs.release.outputs.jmx-metrics-version }}
jmx-metrics-sha256: ${{ needs.release.outputs.jmx-metrics-sha256 }}
secrets:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}

View File

@ -0,0 +1,75 @@
name: Reusable - Create collector contrib pull request
on:
workflow_call:
inputs:
jmx-metrics-version:
type: string
required: true
jmx-metrics-sha256:
type: string
required: true
secrets:
BOT_TOKEN:
required: true
# to help with partial release build failures
workflow_dispatch:
inputs:
jmx-metrics-version:
description: "JMX metrics version"
required: true
jmx-metrics-sha256:
description: "JMX metrics hash (sha256)"
required: true
jobs:
create-collector-contrib-pull-request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repository: opentelemetry-java-bot/opentelemetry-collector-contrib
# this is the personal access token used for "git push" below
token: ${{ secrets.BOT_TOKEN }}
- name: Initialize pull request branch
env:
VERSION: ${{ inputs.jmx-metrics-version }}
run: |
git remote add upstream https://github.com/open-telemetry/opentelemetry-collector-contrib.git
git fetch upstream
git checkout -b update-opentelemetry-jmx-metrics-to-${VERSION} upstream/main
- name: Update version
env:
VERSION: ${{ inputs.jmx-metrics-version }}
HASH: ${{ inputs.jmx-metrics-sha256 }}
run: |
# NOTE there are intentional tab characters in the line below
sed "/^var jmxMetricsGathererVersions/a \ \"$HASH\": {\n version: \"$VERSION\",\n jar: \"JMX metrics gatherer\",\n }," receiver/jmxreceiver/supported_jars.go
git diff
- name: Set git user
run: |
git config user.name opentelemetry-java-bot
git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com
- name: Create pull request against opentelemetry-collector-contrib
env:
# this is the personal access token used for "gh pr create" below
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
VERSION: ${{ inputs.jmx-metrics-version }}
run: |
message="Update the jmx-metrics version to $VERSION"
body="Update the jmx-metrics version to \`$VERSION\`."
# 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
git commit -a -m "$message"
git push --set-upstream origin HEAD:update-opentelemetry-jmx-metrics-to-${VERSION}
gh pr create --title "$message" \
--body "$body" \
--repo open-telemetry/opentelemetry-collector-contrib \
--base main