From fb90b71c1a51380650b5213572e065d7e2b930c5 Mon Sep 17 00:00:00 2001 From: Jeremias Peier Date: Mon, 28 Oct 2024 15:28:50 +0100 Subject: [PATCH] build: fix cherry picking --- .github/workflows/maintenance-changelog.yml | 62 ------------------- .github/workflows/maintenance-cherry-pick.yml | 7 ++- .github/workflows/release-please.yml | 24 +++++++ 3 files changed, 29 insertions(+), 64 deletions(-) delete mode 100644 .github/workflows/maintenance-changelog.yml diff --git a/.github/workflows/maintenance-changelog.yml b/.github/workflows/maintenance-changelog.yml deleted file mode 100644 index a4df84bffb..0000000000 --- a/.github/workflows/maintenance-changelog.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: cherry-pick changelog from release branch into default branch - -on: - push: - tags: ['*.*'] - -permissions: - actions: write - issues: write - -jobs: - cherry_pick: - runs-on: ubuntu-latest - outputs: - failed_release_version: ${{ steps.cherry_pick_error.outputs.failed_release_version }} - steps: - - name: Get token - id: get_token - uses: tibdex/github-app-token@v2 - with: - app_id: ${{ secrets.MAINTENANCE_APP_ID }} - private_key: ${{ secrets.MAINTENANCE_APP_PEM }} - - uses: actions/checkout@v4 - with: - token: ${{ steps.get_token.outputs.app_token }} - fetch-depth: 0 - - name: Get tag name - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Get commit for tag - run: echo "TAG_COMMIT=$(git rev-list -n 1 ${{ env.RELEASE_VERSION }})" >> $GITHUB_ENV - - name: Cherry-pick CHANGELOG.md into ${{ github.event.repository.default_branch }} - run: | - git config user.email "github-actions@github.com" - git config user.name "github-actions" - git checkout ${{ github.event.repository.default_branch }} - git show ${{ env.TAG_COMMIT }} -- CHANGELOG.md | git apply - - git commit -a -m "chore: update changelog" - git push - - name: Handling error - if: ${{ failure() }} - id: cherry_pick_error - run: echo "failed_release_version=$(echo ${{ env.RELEASE_VERSION }})" >> $GITHUB_OUTPUT - - update_maintenance_issue: - runs-on: ubuntu-latest - needs: cherry_pick - if: always() && needs.cherry_pick.result == 'failure' - steps: - - run: echo ${{ needs.cherry_pick.outputs.failed_release_version }} - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - if: needs.cherry_pick.outputs.failed_release_version - with: - node-version-file: .nvmrc - - run: yarn install --frozen-lockfile --non-interactive - if: needs.cherry_pick.outputs.failed_release_version - - name: Update maintenance issue - if: needs.cherry_pick.outputs.failed_release_version - run: yarn ts-hooks scripts/update-maintenance-issue.ts - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - FAILED_RELEASE: ${{ needs.cherry_pick.outputs.failed_release_version }} diff --git a/.github/workflows/maintenance-cherry-pick.yml b/.github/workflows/maintenance-cherry-pick.yml index a0c45592e0..af24a41505 100644 --- a/.github/workflows/maintenance-cherry-pick.yml +++ b/.github/workflows/maintenance-cherry-pick.yml @@ -1,8 +1,11 @@ -name: cherry-pick into target branches +name: Cherry-pick into target branches on: pull_request: - types: [closed] + types: + - closed + branches: + - main permissions: actions: write diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 87c5d55a0d..3bf5b84db3 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -39,9 +39,16 @@ jobs: env: VERSION: ${{ steps.release.outputs.version }} + - name: Get token + id: get_token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.MAINTENANCE_APP_ID }} + private_key: ${{ secrets.MAINTENANCE_APP_PEM }} - uses: actions/checkout@v4 with: fetch-depth: 0 + token: ${{ steps.get_token.outputs.app_token }} - uses: actions/setup-node@v4 with: node-version-file: .nvmrc @@ -98,3 +105,20 @@ jobs: docker push $IMAGE_REPO_STORYBOOK:dev env: DOCKER_BUILDKIT: 1 + + - name: Cherry-pick CHANGELOG.md into ${{ github.event.repository.default_branch }} + if: ${{ steps.release.outputs.release_created && github.ref_name != 'main' }} + run: | + git config user.email "github-actions@github.com" + git config user.name "github-actions" + git checkout ${{ github.event.repository.default_branch }} + git show ${{ github.sha }} -- CHANGELOG.md | git apply - + git commit -a -m "chore: update changelog" + git push + + - name: Update maintenance issue + if: ${{ steps.release.outputs.release_created && failure() }} + run: yarn ts-hooks scripts/update-maintenance-issue.ts + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FAILED_RELEASE: ${{ steps.release.outputs.version }}