Skip to content

add dependabot auto-merge on prs #27

add dependabot auto-merge on prs

add dependabot auto-merge on prs #27

Workflow file for this run

name: PR Build
on:
pull_request:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
create_matrix:
uses: ./.github/workflows/create_matrix.yml
with:
image_directory: "./images"
build:
runs-on: ubuntu-latest
needs: create_matrix
strategy:
matrix:
image_folder: ${{fromJson(needs.create_matrix.outputs.matrix)}}
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Set Image Name output
run: echo "image_name=$(python3 -c "print('${{ matrix.image_folder }}'.split('/')[-1])")" >> $GITHUB_OUTPUT
id: set_image_name
- name: Set up Docker
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Build and push to GHA
uses: docker/build-push-action@v5
with:
context: ${{ matrix.image_folder }}/.
push: true
tags: localhost:5000/${{ steps.set_image_name.outputs.image_name }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Check build status
run: docker run --rm localhost:5000/${{ steps.set_image_name.outputs.image_name }}:latest
dependabot:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
needs: build
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
if: contains(steps.metadata.outputs.dependency-names, 'docker') && steps.metadata.outputs.update-type == 'version-update:semver-patch'
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}