added mock data for aws staging #616
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto approve & merge Dependabot and Renovate PRs | |
| on: | |
| pull_request: | |
| types: [opened, edited, synchronize, reopened, labeled] | |
| branches: [master] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| auto-approve-merge: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| if: github.repository == 'internetee/registry' | |
| uses: actions/checkout@v5 | |
| - name: Install GitHub CLI | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gh | |
| - name: Auto approve PR | |
| if: | | |
| github.actor == 'dependabot[bot]' || | |
| github.actor == 'renovate[bot]' | |
| uses: hmarr/auto-approve-action@v3 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Fetch Dependabot metadata | |
| if: github.actor == 'dependabot[bot]' | |
| id: metadata | |
| uses: dependabot/fetch-metadata@v1 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if PR should be auto-merged | |
| id: check_auto_merge | |
| run: | | |
| # Set default UPDATE_TYPE to avoid unbound variable errors | |
| UPDATE_TYPE="${{ steps.metadata.outputs.update-type || 'unknown' }}" | |
| if [ "${{ github.actor }}" == "dependabot[bot]" ]; then | |
| if [[ "$UPDATE_TYPE" == "version-update:semver-patch" ]]; then | |
| echo "auto_merge=true" >> $GITHUB_OUTPUT | |
| echo "update_type=${UPDATE_TYPE}" >> $GITHUB_OUTPUT | |
| echo "Auto-merge: Dependabot patch update detected" | |
| else | |
| echo "auto_merge=false" >> $GITHUB_OUTPUT | |
| echo "update_type=${UPDATE_TYPE}" >> $GITHUB_OUTPUT | |
| echo "Auto-merge: Dependabot non-patch update, skipping" | |
| fi | |
| elif [ "${{ github.actor }}" == "renovate[bot]" ]; then | |
| # Check if the PR has the 'patch' label but NOT 'minor' or 'major' labels | |
| LABELS=$(gh pr view ${{ github.event.pull_request.number }} --json labels -q '.labels[].name' | tr '\n' ' ') | |
| if [[ "$LABELS" == *"patch"* ]] && [[ "$LABELS" != *"minor"* ]] && [[ "$LABELS" != *"major"* ]]; then | |
| echo "auto_merge=true" >> $GITHUB_OUTPUT | |
| echo "update_type=renovate-patch-only" >> $GITHUB_OUTPUT | |
| else | |
| echo "auto_merge=false" >> $GITHUB_OUTPUT | |
| echo "update_type=renovate-non-patch-or-mixed" >> $GITHUB_OUTPUT | |
| fi | |
| else | |
| echo "auto_merge=false" >> $GITHUB_OUTPUT | |
| echo "update_type=${UPDATE_TYPE}" >> $GITHUB_OUTPUT | |
| echo "Auto-merge: Unknown actor, skipping" | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| shell: bash | |
| - name: Wait for CI checks | |
| if: steps.check_auto_merge.outputs.auto_merge == 'true' | |
| uses: lewagon/wait-on-check-action@v1.3.4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| wait-interval: 30 | |
| - name: Auto-merge PR | |
| if: steps.check_auto_merge.outputs.auto_merge == 'true' | |
| run: | | |
| echo "Attempting to auto-merge PR #${{ github.event.pull_request.number }}" | |
| gh pr merge --auto --merge ${{ github.event.pull_request.number }} || { | |
| echo "Auto-merge failed, but continuing..." | |
| exit 0 | |
| } | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |