Skip to content

Update actions/checkout action to v4 #208

Update actions/checkout action to v4

Update actions/checkout action to v4 #208

Workflow file for this run

name: "docker"
on:
pull_request:
types: [opened, synchronize, reopened]
release:
types:
- created
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: "Checkout source code at current commit"
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- name: Prepare tags for Docker image
if: (github.event_name == 'release' && github.event.action == 'created') || github.event.pull_request.head.repo.full_name == github.repository
id: prepare
run: |
TAGS=${{ github.repository }}:sha-${GITHUB_SHA:0:7}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.pull_request.number }}-merge
fi
if [[ -n $VERSION ]]; then
TAGS="$TAGS,${{ github.repository }}:${VERSION}"
fi
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${{ github.repository }}:latest"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
if: (github.event_name == 'release' && github.event.action == 'created') || github.event.pull_request.head.repo.full_name == github.repository
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: "Build and push docker image to DockerHub"
id: docker_build
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
push: ${{ (github.event_name == 'release' && github.event.action == 'created') || github.event.pull_request.head.repo.full_name == github.repository }}
tags: ${{ steps.prepare.outputs.tags }}