Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): use opentelemetrybot to sync package-lock.json on release PRs #1817

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,52 @@ jobs:
node-version: 18
registry-url: 'https://registry.npmjs.org'

- name: Build Packages
- name: Install packages
run: |
npm ci
npm run compile

- uses: google-github-actions/release-please-action@v3
id: release
with:
command: manifest
token: ${{secrets.RELEASE_PR_TOKEN}}
token: ${{secrets.OPENTELEMETRYBOT_GITHUB_TOKEN}}
default-branch: main

# get release PR as we're currently on main
- name: Checkout release PR
# only checkout if a PR has been created, otherwise this will fail
if: ${{ steps.release.outputs.pr }}
uses: actions/checkout@v4
with:
ref: release-please--branches--main
# use a token so that workflows on the PR run when we push later
token: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}

# release-please does not do this on its own, so we do it here instead
- name: Update package-lock.json in PR
env:
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
# only update if a PR has been created
if: ${{ steps.release.outputs.pr }}
run: |
npm install --ignore-scripts --package-lock-only
git add package-lock.json
git config user.name opentelemetrybot
git config user.email [email protected]
git commit -m "chore: sync package-lock.json"
git push

# get main again
- name: Checkout Repository
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: if you want to speed up the process you could avoid checking out again by cleaning up the workspace just after pushing you could add the following commands

git clean -xdf
npm ci
npm run compile

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes we'd also have to check out main though as we might be on another branch at this point in the workflow.

It's also relatively quick (about 2s) compared to the rest of the workflow so I'd opt to keep it as-is (here's an example run https://github.com/pichlermarc-sample-organization/test-release-please/actions/runs/6941681633/job/18883019651). 🙂

uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Rebuild Packages
run: |
npm ci
npm run compile

# Release Please has already incremented versions and published tags, so we just
# need to publish all unpublished versions to npm here
# See: https://github.com/lerna/lerna/tree/main/commands/publish#bump-from-package
Expand Down
Loading