From fce33b64cd83c2955a23382da8e4c5fedfc794b7 Mon Sep 17 00:00:00 2001 From: Marc Pichler Date: Wed, 22 Nov 2023 09:48:41 +0100 Subject: [PATCH] fix(ci): use opentelemetrybot to sync package-lock.json on release PRs (#1817) * fix(ci): use opentelemetrybot to sync package-lock.json on release PRs * fix: comment typo * fix: token is named RELEASE_PR_TOKEN --- .github/workflows/release-please.yml | 38 ++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index b646e18251..e9bb568c0b 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -20,10 +20,9 @@ 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 @@ -32,6 +31,41 @@ jobs: token: ${{secrets.RELEASE_PR_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.RELEASE_PR_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.RELEASE_PR_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 107717825+opentelemetrybot@users.noreply.github.com + git commit -m "chore: sync package-lock.json" + git push + + # get main again + - name: Checkout Repository + 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