setup build job

This commit is contained in:
Dmitry Sichkar 2024-01-07 15:47:12 +02:00
parent 90aea066ff
commit d1026a3eb9

62
.github/workflows/docker.yml vendored Normal file
View File

@ -0,0 +1,62 @@
name: Docker build images
on:
schedule:
- cron: "0 10 * * 1" # everyday Monday at 10am
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
branches:
- 'main'
env:
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
jobs:
main:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set image name based on the repository name
id: step_one
run: |
IMAGE_NAME="${GITHUB_REPOSITORY/docker-/}"
echo $IMAGE_NAME
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
- 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 != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Buildx cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/cache
key: ${{ runner.os }}-docker-${{ hashFiles('cache/**') }}
restore-keys: |
${{ runner.os }}-docker
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
platforms: ${{ env.platforms }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=${{ github.workspace }}/cache
cache-to: type=local,dest=${{ github.workspace }}/cache