Bump dependabot/fetch-metadata from 1.6.0 to 2.0.0 #265
Workflow file for this run
This file contains 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: Build container image | |
on: | |
push: | |
branches: [ main, devel ] | |
pull_request: | |
types: [ assigned, opened, synchronize, reopened ] | |
schedule: | |
- cron: "32 02 * * 0" | |
workflow_dispatch: | |
env: | |
PLATFORMS: ${{ fromJSON('[ "linux/amd64", "linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le" ]')[ github.event_name != 'pull_request' ] }} | |
IMAGENAME: imapfetch | |
jobs: | |
container: | |
name: build image 📦 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Prepare Tags | |
id: prep | |
shell: bash | |
run: | | |
TAGS=() | |
case "${GITHUB_REF}" in | |
# version releases | |
refs/tags/*) | |
VERSION="${GITHUB_REF#refs/tags/}" | |
if [[ ${VERSION} =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | |
V=("${BASH_REMATCH[@]}") | |
TAGS+=("${{ env.IMAGENAME }}:${V[1]}" \ | |
"${{ env.IMAGENAME }}:${V[1]}.${V[2]}" \ | |
"${{ env.IMAGENAME }}:${V[1]}.${V[2]}.${V[3]}") | |
else | |
TAGS+=("${{ env.IMAGENAME }}:${VERSION}") | |
fi | |
;& | |
# branch heads (+ fallthorugh) | |
refs/heads/*) | |
TAGS+=("${{ env.IMAGENAME }}:latest") | |
TAGS=$({ IFS=","; echo "${TAGS[*]/#/ghcr.io/${{ github.repository_owner }}/}"; }) | |
;; | |
# pull requests | |
refs/pull/*) | |
TAGS=("${{ github.repository_owner }}/${{ env.IMAGENAME }}:pr-${{ github.event.number }}") | |
;; | |
esac | |
echo "TAGS ${TAGS}" | |
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
echo "head=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3.0.0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.2.0 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3.1.0 | |
if: ${{ github.event_name != 'pull_request' && steps.prep.outputs.head != 'devel' }} | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5.3.0 | |
with: | |
context: . | |
file: assets/Dockerfile | |
platforms: ${{ env.PLATFORMS }} | |
push: ${{ github.event_name != 'pull_request' && steps.prep.outputs.head != 'devel' }} | |
tags: ${{ steps.prep.outputs.tags }} | |
labels: | | |
org.opencontainers.image.title=${{ github.event.repository.name }} | |
org.opencontainers.image.description=${{ github.event.repository.description }} | |
org.opencontainers.image.url=${{ github.event.repository.html_url }} | |
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | |
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }} | |
dependabot: | |
# https://nicolasiensen.github.io/2022-07-23-automating-dependency-updates-with-dependabot-github-auto-merge-and-github-actions/ | |
name: merge dependabot pr 🏗️ | |
needs: [ container ] | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' }} | |
permissions: | |
pull-requests: write | |
contents: write | |
steps: | |
- name: Get Dependabot metadata | |
id: dependabot-metadata | |
uses: dependabot/fetch-metadata@v2.0.0 | |
- name: Enable auto-merge for PR | |
run: | | |
gh pr merge --auto --rebase "$PR" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR: ${{ github.event.pull_request.html_url }} | |
- name: Approve patch and minor updates | |
if: ${{ steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor' }} | |
run: | | |
gh pr review "$PR" --approve --body "Automatically **approving** this pull request because it includes a **patch or minor** update." | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR: ${{ github.event.pull_request.html_url }} | |
- name: Comment on major updates | |
if: ${{ steps.dependabot-metadata.outputs.update-type == 'version-update:semver-major' }} | |
run: | | |
gh pr comment "$PR" --body "Requires manual approval due to **major update**." | |
gh pr edit "$PR" --add-label "dependabot-major" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR: ${{ github.event.pull_request.html_url }} | |