ci: migrate to otelbot (#5920)
This commit is contained in:
parent
c732e7b51e
commit
fbbce6e1c0
|
|
@ -25,23 +25,8 @@ jobs:
|
|||
create-or-update-release-pr:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Fork
|
||||
run: gh repo fork open-telemetry/opentelemetry-js
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
repository: opentelemetrybot/opentelemetry-js
|
||||
ref: main
|
||||
token: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
|
||||
- name: Sync with upstream
|
||||
run: |
|
||||
git remote show origin
|
||||
git remote add upstream https://github.com/open-telemetry/opentelemetry-js.git
|
||||
git fetch upstream
|
||||
git reset --hard upstream/main
|
||||
git push origin main --force
|
||||
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
|
|
@ -52,14 +37,19 @@ jobs:
|
|||
|
||||
- run: npm ci
|
||||
|
||||
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
|
||||
id: otelbot-token
|
||||
with:
|
||||
app-id: ${{ vars.OTELBOT_APP_ID }}
|
||||
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
|
||||
|
||||
- name: Create/Update Release PR
|
||||
run: |
|
||||
git config user.name opentelemetrybot
|
||||
git config user.email 107717825+opentelemetrybot@users.noreply.github.com
|
||||
git config user.name otelbot
|
||||
git config user.email 197425009+otelbot@users.noreply.github.com
|
||||
npm run github:create_or_update_release_pr
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
|
||||
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
|
||||
RELEASE_SCOPE: ${{ github.event.inputs.release_scope }}
|
||||
RELEASE_KIND: ${{ github.event.inputs.release_scope }}:${{ github.event.inputs.release_type }}
|
||||
RELEASE_PR_REMOTE: origin
|
||||
RELEASE_PR_OWNER: opentelemetrybot
|
||||
|
|
|
|||
|
|
@ -9,36 +9,40 @@ permissions:
|
|||
|
||||
env:
|
||||
PR_NUM: ${{ github.event.pull_request.number }}
|
||||
SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=open-telemetry/opentelemetry-js
|
||||
SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
comment-on-pr:
|
||||
name: Add survey to PR if author is not a member
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
if: github.event.pull_request.merged == true
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Check if user is a member of the org
|
||||
id: check-membership
|
||||
run: |
|
||||
USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
|
||||
ORG="${{ github.repository_owner }}"
|
||||
STATUS=$(gh api "orgs/$ORG/members/$USERNAME" --silent && echo "true" || echo "false")
|
||||
if [[ "$STATUS" == "true" ]]; then
|
||||
echo "MEMBER_FOUND=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "MEMBER_FOUND=false" >> $GITHUB_ENV
|
||||
fi
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
|
||||
- uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1
|
||||
id: otelbot-token
|
||||
with:
|
||||
app-id: ${{ vars.OTELBOT_APP_ID }}
|
||||
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
|
||||
|
||||
- name: Add comment to PR if author is not a member
|
||||
if: env.MEMBER_FOUND == 'false'
|
||||
- name: Add survey comment if author is not a member or bot
|
||||
run: |
|
||||
USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
|
||||
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})."
|
||||
USERNAME="${{ github.event.pull_request.user.login }}"
|
||||
USER_TYPE="${{ github.event.pull_request.user.type }}"
|
||||
ORG="${{ github.repository_owner }}"
|
||||
|
||||
# Skip if user is a bot
|
||||
if [[ "$USER_TYPE" == "Bot" ]]; then
|
||||
echo "Skipping survey for bot user: $USERNAME"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Skip if user is an org member
|
||||
if gh api "orgs/$ORG/members/$USERNAME" --silent; then
|
||||
echo "Skipping survey for org member: $USERNAME"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Add survey comment for external contributor
|
||||
echo "Adding survey comment for external contributor: $USERNAME"
|
||||
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})."
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
|
||||
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ We aim to eventually automate this process as much as possible.
|
|||
|
||||
## 2. Review and merge the release PR
|
||||
|
||||
1. Review the PR generated via the workflow (it will be titled `chore: prepare next release` and opened by the @opentelemetrybot user)
|
||||
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))
|
||||
2. Once approved, merge the PR
|
||||
|
||||
## 3. Publish to NPM
|
||||
|
|
|
|||
|
|
@ -64,14 +64,14 @@
|
|||
"_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",
|
||||
"_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",
|
||||
"_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",
|
||||
"_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",
|
||||
"_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",
|
||||
"_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",
|
||||
"_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",
|
||||
"_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",
|
||||
"_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",
|
||||
"_verify_release_kind": "echo $RELEASE_KIND | grep -oE '^(all|sdk|experimental|semconv):(minor|patch)$'",
|
||||
"_verify_release_remote": "git remote get-url $RELEASE_PR_REMOTE",
|
||||
"_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)",
|
||||
"_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)",
|
||||
"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)"
|
||||
},
|
||||
"repository": "open-telemetry/opentelemetry-js",
|
||||
|
|
|
|||
Loading…
Reference in New Issue