Skip to content

chore(deps): update stefanzweifel/git-auto-commit-action action to v5… #151

chore(deps): update stefanzweifel/git-auto-commit-action action to v5…

chore(deps): update stefanzweifel/git-auto-commit-action action to v5… #151

name: build-and-push-docker-image
permissions: read-all
on:
push:
branches:
- main
jobs:
docker:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
# Checks out the main branch of the repository to the runner
- name: checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
fetch-depth: "0"
# This action creates a new git tag of the main branch with the new version number
- name: Bump version and push tag
id: bumpTag
uses: anothrNick/github-tag-action@a2c70ae13a881faf2b4953baaa9e49731997ab36 # 1.67.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
# Sets up the QEMU emulator that emulates different architectures
- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
# Sets up the Docker Buildx plugin to build multi-architecture Docker images
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
# Authenticates with Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Authenticates with the GitHub Container Registry
- name: Login to GitHub Package Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: metadata
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
# type=raw,value={{branch}}
# Builds and pushes the Docker image to Docker Hub and the GitHub Container Registry with the following tags:
# - 'latest' for successful builds on the main branch.
# - '<short_branch_name>' pushes to non-main branches.
- name: Build and push Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@5875562561d22a34be0c657405578705a169af6c # v1.9.1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# Create a release based on the new tag
- name: Create release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
tag_name: ${{ steps.bumpTag.outputs.new_tag }}
env:
GITHUB_TOKEN: ${{ secrets.PAT }}