From f3d5471e60ec52c242b390abee80e84669b6f878 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Wed, 7 Aug 2024 23:02:07 -0700 Subject: [PATCH 1/3] Label with Zorgbort Again I think this issue with this was a bug, we actually must label these PRs with zorgbort otherwise github won't run the followup workflows and test. --- .github/workflows/auto-merge.yml | 8 ++------ .../workflows/update-transitive-dependencies.yaml | 12 ++++-------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index ee933248f2..2167e7c6e3 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -44,15 +44,11 @@ jobs: github-token: "${{ secrets.GITHUB_TOKEN }}" - uses: actions/checkout@v4 if: ${{contains(steps.metadata.outputs.dependency-names, matrix.safe-dependency) && (steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch') }} - - name: Review and Label + - name: Enable Auto Merge if: ${{contains(steps.metadata.outputs.dependency-names, matrix.safe-dependency) && (steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch') }} run: | + gh pr merge --merge --auto ${{ github.event.number }} gh pr edit --add-label "ready to merge" ${{ github.event.number }} gh pr review --approve -b "Auto Approved" ${{ github.event.number }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Enable Auto Merge - if: ${{contains(steps.metadata.outputs.dependency-names, matrix.safe-dependency) && (steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch') }} - run: gh pr merge --merge --auto ${{ github.event.number }} env: GH_TOKEN: ${{ secrets.ZORGBORT_TOKEN }} diff --git a/.github/workflows/update-transitive-dependencies.yaml b/.github/workflows/update-transitive-dependencies.yaml index a3911cce9b..e089d01038 100644 --- a/.github/workflows/update-transitive-dependencies.yaml +++ b/.github/workflows/update-transitive-dependencies.yaml @@ -38,18 +38,14 @@ jobs: [1]: https://github.com/peter-evans/create-pull-request branch: auto-update-dependencies labels: dependencies,run percy tests - - name: Add Ready Label - if: steps.cpr.outputs.pull-request-operation == 'created' - run: gh pr edit --add-label "ready to merge" ${{ steps.cpr.outputs.pull-request-number }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Approve Pull Request - if: steps.cpr.outputs.pull-request-operation == 'created' run: gh pr review --approve -b "Auto Approved" ${{ steps.cpr.outputs.pull-request-number }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Enable Pull Request Automerge + - name: Enable Pull Request Automerge and Label for Tests if: steps.cpr.outputs.pull-request-operation == 'created' - run: gh pr merge --merge --auto ${{ steps.cpr.outputs.pull-request-number }} + run: | + gh pr edit --add-label "ready to merge" ${{ steps.cpr.outputs.pull-request-number }} + gh pr merge --merge --auto ${{ steps.cpr.outputs.pull-request-number }} env: GH_TOKEN: ${{ secrets.ZORGBORT_TOKEN }} From c8fb455929a352b3568fe6dabe4755a469f3f61f Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Thu, 8 Aug 2024 16:10:03 -0700 Subject: [PATCH 2/3] Refactor Automerge Some readability and output improvements here: 1. Instead of running these as a matrix do the match check in a single statement. It's a long line, but it means we won't have 25 jobs to scroll through in the status check on github. 2. Do each check and then create a readable output. Hopefully this makes it a bit easier to see what's happening here. 3. Have the merge job depend on the check job so we shouldn't get any failures and can just run the test a single time. --- .github/workflows/auto-merge.yml | 60 ++++++++++++-------------------- 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index 2167e7c6e3..8d5b91efe6 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -1,52 +1,36 @@ name: Dependabot auto-merge -on: pull_request_target -permissions: - pull-requests: write - contents: write +on: pull_request jobs: - dependabot: + check: runs-on: ubuntu-latest - strategy: - matrix: - safe-dependency: - - "@embroider/test-setup" - - "@embroider/util" - - "@formatjs/intl-locale" - - "@formatjs/intl-pluralrules" - - "@formatjs/intl-relativetimeformat" - - "@percy/cli" - - "@percy/ember" - - "@sentry/ember" - - broccoli-file-creator - - broccoli-funnel - - broccoli-merge-trees - - browserslist - - caniuse-db - - ember-a11y-testing - - ember-cli-bundle-analyzer - - ember-cli-dependency-checker - - ember-cli-dependency-lint - - ember-cli-deprecation-workflow - - ember-mirage - - ember-cli-page-object - - ember-noscript - - ember-qunit-nice-errors - - ember-template-lint - - ember-test-selectors - - stylelint-config-recommended-scss - - stylelint-scss + name: Determine Automerge Status if: ${{ github.actor == 'dependabot[bot]' }} + outputs: + shouldMerge: ${{ steps.should_merge.outputs.shouldMerge }} + env: + SAFE_DEPENDENCIES: "@embroider/test-setup,@embroider/util,@formatjs/intl-locale,@formatjs/intl-pluralrules,@formatjs/intl-relativetimeformat,@percy/cli,@percy/ember,@sentry/ember,broccoli-file-creator,broccoli-funnel,broccoli-merge-trees,browserslist,caniuse-db,ember-a11y-testing,ember-cli-bundle-analyzer,ember-cli-dependency-checker,ember-cli-dependency-lint,ember-cli-deprecation-workflow,ember-mirage,ember-cli-page-object,ember-noscript,ember-qunit-nice-errors,ember-template-lint,ember-test-selectors,stylelint-config-recommended-scss,stylelint-scss" steps: - name: Dependabot metadata id: metadata uses: dependabot/fetch-metadata@v2.2.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" + - run: > + npx in-string-list ${{ steps.metadata.outputs.dependency-names }} ${{ env.SAFE_DEPENDENCIES }} + && echo "isSafe=yes" >> "$GITHUB_OUTPUT" + - run: > + ${{ steps.metadata.outputs.update-type }} != 'version-update:semver-major' + && echo "isNotMajor=yes" >> "$GITHUB_OUTPUT" + - id: should_merge + run: (test -z {{env.isSafe}} && test -z {{env.isNotMajor}}) && echo "shouldMerge=yes" >> "$GITHUB_OUTPUT" + auto_merge: + runs-on: ubuntu-latest + needs: check + if: needs.check.outputs.shouldMerge == 'yes' + name: Approve, label, and merge + steps: - uses: actions/checkout@v4 - if: ${{contains(steps.metadata.outputs.dependency-names, matrix.safe-dependency) && (steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch') }} - - name: Enable Auto Merge - if: ${{contains(steps.metadata.outputs.dependency-names, matrix.safe-dependency) && (steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch') }} - run: | + - run: | gh pr merge --merge --auto ${{ github.event.number }} gh pr edit --add-label "ready to merge" ${{ github.event.number }} gh pr review --approve -b "Auto Approved" ${{ github.event.number }} From 370a9d06a70f9d555920da367e311599ba92b736 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Thu, 8 Aug 2024 16:13:31 -0700 Subject: [PATCH 3/3] Rename Automerge This is entirely a dependabot workflow, name it appropriately --- .github/workflows/{auto-merge.yml => dependabot-automerge.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{auto-merge.yml => dependabot-automerge.yml} (100%) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/dependabot-automerge.yml similarity index 100% rename from .github/workflows/auto-merge.yml rename to .github/workflows/dependabot-automerge.yml