Skip to content

Workflow file for this run

name: Build and Push Docker Image
on:
release:
types: [created]
workflow_dispatch:
inputs:
version:
description: 'Versione'
required: true
env:
IMAGE_NAME: anime_downloader
jobs:
build_and_push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check Out Repo
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Set env
if: github.event_name != 'workflow_dispatch'
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set env
if: github.event_name == 'workflow_dispatch'
run: echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Set env
if: github.ref_name == 'dev'
run: echo "RELEASE_VERSION=dev" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.IMAGE_NAME }}
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
flavor: |
latest=${{ github.event_name != 'workflow_dispatch' || github.ref_name != 'dev' }}
tags: |
type=raw,enable=true,value=dev
type=raw,enable=true,value=${{ env.RELEASE_VERSION }}
- name: Print INFO
run: |
echo "Event: ${{ github.event_name }}"
echo "Version: ${{ env.RELEASE_VERSION }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
echo "Tags: ${{ steps.meta.outputs.tags }}"
- name: Build latest and push
id: docker_build_latest
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
platforms: linux/arm/v7,linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: set_version=${{ env.RELEASE_VERSION }}
- name: Image latest digest
run: echo ${{ steps.docker_build_latest.outputs.digest }}