Skip to content

Commit fbbce6e

Browse files
authored
ci: migrate to otelbot (open-telemetry#5920)
1 parent c732e7b commit fbbce6e

File tree

4 files changed

+38
-44
lines changed

4 files changed

+38
-44
lines changed

.github/workflows/create-or-update-release-pr.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,8 @@ jobs:
2525
create-or-update-release-pr:
2626
runs-on: ubuntu-latest
2727
steps:
28-
- name: Fork
29-
run: gh repo fork open-telemetry/opentelemetry-js
30-
env:
31-
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
3228
- name: Checkout
3329
uses: actions/checkout@v5
34-
with:
35-
repository: opentelemetrybot/opentelemetry-js
36-
ref: main
37-
token: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
38-
- name: Sync with upstream
39-
run: |
40-
git remote show origin
41-
git remote add upstream https://github.com/open-telemetry/opentelemetry-js.git
42-
git fetch upstream
43-
git reset --hard upstream/main
44-
git push origin main --force
4530

4631
- uses: actions/setup-node@v5
4732
with:
@@ -52,14 +37,19 @@ jobs:
5237

5338
- run: npm ci
5439

40+
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
41+
id: otelbot-token
42+
with:
43+
app-id: ${{ vars.OTELBOT_APP_ID }}
44+
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
45+
5546
- name: Create/Update Release PR
5647
run: |
57-
git config user.name opentelemetrybot
58-
git config user.email 107717825+opentelemetrybot@users.noreply.github.com
48+
git config user.name otelbot
49+
git config user.email 197425009+otelbot@users.noreply.github.com
5950
npm run github:create_or_update_release_pr
6051
env:
61-
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
52+
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
6253
RELEASE_SCOPE: ${{ github.event.inputs.release_scope }}
6354
RELEASE_KIND: ${{ github.event.inputs.release_scope }}:${{ github.event.inputs.release_type }}
6455
RELEASE_PR_REMOTE: origin
65-
RELEASE_PR_OWNER: opentelemetrybot

.github/workflows/survey-on-merged-pr.yml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,40 @@ permissions:
99

1010
env:
1111
PR_NUM: ${{ github.event.pull_request.number }}
12-
SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=open-telemetry/opentelemetry-js
12+
SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=${{ github.repository }}
1313

1414
jobs:
1515
comment-on-pr:
1616
name: Add survey to PR if author is not a member
1717
runs-on: ubuntu-latest
18-
permissions:
19-
contents: write
20-
pull-requests: write
2118
if: github.event.pull_request.merged == true
2219
steps:
23-
- uses: actions/checkout@v5
24-
- name: Check if user is a member of the org
25-
id: check-membership
20+
- uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1
21+
id: otelbot-token
22+
with:
23+
app-id: ${{ vars.OTELBOT_APP_ID }}
24+
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
25+
26+
- name: Add survey comment if author is not a member or bot
2627
run: |
27-
USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
28+
USERNAME="${{ github.event.pull_request.user.login }}"
29+
USER_TYPE="${{ github.event.pull_request.user.type }}"
2830
ORG="${{ github.repository_owner }}"
29-
STATUS=$(gh api "orgs/$ORG/members/$USERNAME" --silent && echo "true" || echo "false")
30-
if [[ "$STATUS" == "true" ]]; then
31-
echo "MEMBER_FOUND=true" >> $GITHUB_ENV
32-
else
33-
echo "MEMBER_FOUND=false" >> $GITHUB_ENV
31+
32+
# Skip if user is a bot
33+
if [[ "$USER_TYPE" == "Bot" ]]; then
34+
echo "Skipping survey for bot user: $USERNAME"
35+
exit 0
3436
fi
37+
38+
# Skip if user is an org member
39+
if gh api "orgs/$ORG/members/$USERNAME" --silent; then
40+
echo "Skipping survey for org member: $USERNAME"
41+
exit 0
42+
fi
43+
44+
# Add survey comment for external contributor
45+
echo "Adding survey comment for external contributor: $USERNAME"
46+
gh pr comment ${PR_NUM} --repo ${{ github.repository }} --body "Thank you for your contribution @${USERNAME}! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this [survey](${SURVEY_URL})."
3547
env:
36-
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
37-
38-
- name: Add comment to PR if author is not a member
39-
if: env.MEMBER_FOUND == 'false'
40-
run: |
41-
USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
42-
gh pr comment ${PR_NUM} --repo open-telemetry/opentelemetry-js --body "Thank you for your contribution @${USERNAME}! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this [survey](${SURVEY_URL})."
43-
env:
44-
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
48+
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}

doc/contributing/releasing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ We aim to eventually automate this process as much as possible.
2020
2121
## 2. Review and merge the release PR
2222

23-
1. Review the PR generated via the workflow (it will be titled `chore: prepare next release` and opened by the @opentelemetrybot user)
23+
1. Review the PR generated via the workflow (it will be titled `chore: prepare next release` and opened by [otelbot[bot]](https://github.com/apps/otelbot))
2424
2. Once approved, merge the PR
2525

2626
## 3. Publish to NPM

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@
6464
"_github:draft_release:experimental": "node scripts/extract-latest-release-notes.js ./experimental/CHANGELOG.md && VERSION=$(node scripts/get-version.js ./experimental/packages/ | grep -oE '^[0-9]+\\.[0-9]+\\.[0-9]+$') && gh release create --draft --notes-file ./.tmp/release-notes.md --target main --title experimental/v$VERSION experimental/v$VERSION",
6565
"_github:draft_release:stable": "node scripts/extract-latest-release-notes.js ./CHANGELOG.md && VERSION=$(node scripts/get-version.js ./packages/ | grep -oE '^[0-9]+\\.[0-9]+\\.[0-9]+$') && gh release create --draft --notes-file ./.tmp/release-notes.md --target main --title v$VERSION v$VERSION",
6666
"_github:draft_release:semconv": "node scripts/extract-latest-release-notes.js ./semantic-conventions/CHANGELOG.md && VERSION=$(node scripts/get-version.js ./semantic-conventions/package.json | grep -oE '^[0-9]+\\.[0-9]+\\.[0-9]+$') && gh release create --draft --notes-file ./.tmp/release-notes.md --target main --title semconv/v$VERSION semconv/v$VERSION",
67-
"_github:update_release_pr_body_from_file": "gh pr edit --repo open-telemetry/opentelemetry-js $RELEASE_PR_OWNER:release/next-version --body-file ./.tmp/release-notes.md",
67+
"_github:update_release_pr_body_from_file": "gh pr edit --repo open-telemetry/opentelemetry-js $RELEASE_PR_OWNER:otelbot/prepare-next-version --body-file ./.tmp/release-notes.md",
6868
"_github:update_release_pr_body:all": "node scripts/extract-latest-release-notes.js api/CHANGELOG.md ./CHANGELOG.md experimental/CHANGELOG.md && npm run _github:update_release_pr_body_from_file",
6969
"_github:update_release_pr_body:sdk": "node scripts/extract-latest-release-notes.js ./CHANGELOG.md experimental/CHANGELOG.md && npm run _github:update_release_pr_body_from_file",
7070
"_github:update_release_pr_body:experimental": "node scripts/extract-latest-release-notes.js experimental/CHANGELOG.md && npm run _github:update_release_pr_body_from_file",
7171
"_github:update_release_pr_body:semconv": "node scripts/extract-latest-release-notes.js semantic-conventions/CHANGELOG.md && npm run _github:update_release_pr_body_from_file",
7272
"_verify_release_kind": "echo $RELEASE_KIND | grep -oE '^(all|sdk|experimental|semconv):(minor|patch)$'",
7373
"_verify_release_remote": "git remote get-url $RELEASE_PR_REMOTE",
74-
"_github:update_release_branch": "npm run _verify_release_kind && npm run _verify_release_remote && (git checkout main && git pull upstream main && git branch -D release/next-version; git checkout -b release/next-version && npm run prepare_release:$RELEASE_KIND && git commit -am \"chore: prepare release\" && git push --set-upstream $RELEASE_PR_REMOTE --force release/next-version)",
74+
"_github:update_release_branch": "npm run _verify_release_kind && npm run _verify_release_remote && (git checkout main && git pull upstream main && git branch -D otelbot/prepare-next-version; git checkout -b otelbot/prepare-next-version && npm run prepare_release:$RELEASE_KIND && git commit -am \"chore: prepare release\" && git push --set-upstream $RELEASE_PR_REMOTE --force otelbot/prepare-next-version)",
7575
"github:create_or_update_release_pr": "npm run _github:update_release_branch && (gh pr create --repo open-telemetry/opentelemetry-js --title 'chore: prepare next release' --body ''; npm run _github:update_release_pr_body:$RELEASE_SCOPE)"
7676
},
7777
"repository": "open-telemetry/opentelemetry-js",

0 commit comments

Comments
 (0)