From 01157e1e7222d3100c0dca370851997d45f88743 Mon Sep 17 00:00:00 2001 From: Andy McLeod Date: Wed, 29 Nov 2023 11:28:53 -0500 Subject: [PATCH 1/3] support golang in dependabot automerge --- .github/workflows/dependabot-automerge.yaml | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.github/workflows/dependabot-automerge.yaml b/.github/workflows/dependabot-automerge.yaml index d8031a8..5f0577d 100644 --- a/.github/workflows/dependabot-automerge.yaml +++ b/.github/workflows/dependabot-automerge.yaml @@ -130,3 +130,34 @@ jobs: run: | gh pr review --approve --body "Merging this \`${UPDATE_TYPE}\` update (npm: \`${MERGE_ECOSYSTEM}\`, all: \`${MERGE_ALL}\`)" "$PR_URL" gh pr merge --auto --merge "$PR_URL" + + - name: Merge Go update + if: | + steps.metadata.outputs.package-ecosystem == 'go_modules' && + ( + (inputs.all == 'all' || inputs.go_modules == 'all') || + ( + steps.metadata.outputs.update-type == 'version-update:semver-major' && + (inputs.all == 'major' || inputs.go_modules == 'major') + ) || + ( + steps.metadata.outputs.update-type == 'version-update:semver-minor' && + ( + (inputs.all == 'major' || inputs.go_modules == 'major') || + (inputs.all == 'minor' || inputs.go_modules == 'minor') + ) + ) || + ( + steps.metadata.outputs.update-type == 'version-update:semver-patch' && + (inputs.all != 'none' || inputs.go_modules != 'none') + ) + ) + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MERGE_ALL: ${{ inputs.all }} + MERGE_ECOSYSTEM: ${{ inputs.go_modules }} + UPDATE_TYPE: ${{ steps.metadata.outputs.update-type }} + PR_URL: ${{ github.event.pull_request.html_url }} + run: | + gh pr review --approve --body "Merging this \`${UPDATE_TYPE}\` update (go_modules: \`${MERGE_ECOSYSTEM}\`, all: \`${MERGE_ALL}\`)" "$PR_URL" + gh pr merge --auto --merge "$PR_URL" From 139313f9e41e9100025443c185e430bd49a9e352 Mon Sep 17 00:00:00 2001 From: Andy McLeod Date: Wed, 29 Nov 2023 12:27:32 -0500 Subject: [PATCH 2/3] gomod/go_modules confusion --- .github/workflows/dependabot-automerge.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dependabot-automerge.yaml b/.github/workflows/dependabot-automerge.yaml index 5f0577d..c889cdb 100644 --- a/.github/workflows/dependabot-automerge.yaml +++ b/.github/workflows/dependabot-automerge.yaml @@ -155,9 +155,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MERGE_ALL: ${{ inputs.all }} - MERGE_ECOSYSTEM: ${{ inputs.go_modules }} + MERGE_ECOSYSTEM: ${{ inputs.gomod }} UPDATE_TYPE: ${{ steps.metadata.outputs.update-type }} PR_URL: ${{ github.event.pull_request.html_url }} run: | - gh pr review --approve --body "Merging this \`${UPDATE_TYPE}\` update (go_modules: \`${MERGE_ECOSYSTEM}\`, all: \`${MERGE_ALL}\`)" "$PR_URL" + gh pr review --approve --body "Merging this \`${UPDATE_TYPE}\` update (gomod: \`${MERGE_ECOSYSTEM}\`, all: \`${MERGE_ALL}\`)" "$PR_URL" gh pr merge --auto --merge "$PR_URL" From 0e9cc6d00ed0dde1634db7124f4c5ad64041eb06 Mon Sep 17 00:00:00 2001 From: Andy McLeod Date: Wed, 29 Nov 2023 12:51:18 -0500 Subject: [PATCH 3/3] input validation for gomod --- .github/workflows/dependabot-automerge.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/dependabot-automerge.yaml b/.github/workflows/dependabot-automerge.yaml index c889cdb..9fa99ea 100644 --- a/.github/workflows/dependabot-automerge.yaml +++ b/.github/workflows/dependabot-automerge.yaml @@ -26,6 +26,12 @@ on: default: none description: | GitHub Actions upgrades to automatically merge. Valid values are: all, none, major, minor, patch. + gomod: + required: false + type: string + default: none + description: | + Go upgrades to automatically merge. Valid values are: all, none, major, minor, patch. npm: required: false type: string @@ -57,6 +63,12 @@ jobs: exit 1 fi + echo "gomod=${{ inputs.gomod }}" + if [[ ! "${{ inputs.gomod }}" =~ ^(all|none|major|minor|patch)$ ]]; then + echo "Invalid input: gomod=${{ inputs.gomod }}" + exit 1 + fi + echo "npm=${{ inputs.npm }}" if [[ ! "${{ inputs.npm }}" =~ ^(all|none|major|minor|patch)$ ]]; then echo "Invalid input: npm=${{ inputs.npm }}"