Update docker.yml

This commit is contained in:
Nobix
2022-04-08 07:02:48 +05:30
committed by GitHub
parent b37523ba9e
commit 8850d6ad34
+20 -19
View File
@@ -106,30 +106,33 @@ jobs:
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- -
name: Login to DockerHub name: Login to DockerHub
if: ${{ inputs.dockerhub-enable }} if: $${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
username: ${{ inputs.dockerhub-username }} username: ${{ inputs.dockerhub-username }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Login to GHCR name: Login to GHCR
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }} password: ${{ secrets.GHCR_PAT }}
- # -
name: Docker meta # name: Docker meta
id: docker_meta # id: docker_meta
uses: docker/metadata-action@v3.6.2 # uses: docker/metadata-action@v3.6.2
with: # with:
# list of Docker images to use as base name for tags # # list of Docker images to use as base name for tags
images: ${{ inputs.image-names }} # images: ${{ inputs.image-names }}
flavor: | # flavor: |
latest=false # latest=false
tags: | # tags: |
type=raw,value=latest # type=raw,value=latest
- -
# this will build the images, once per platform, # this will build the images, once per platform,
# then push to both Docker Hub and GHCR # then push to both Docker Hub and GHCR
@@ -137,19 +140,17 @@ jobs:
id: docker_build_and_push id: docker_build_and_push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
platforms: ${{ inputs.platforms }} platforms: linux/amd64
context: ${{ inputs.context }} context: app
target: ${{ inputs.target }}
file: ${{ inputs.file }}
builder: ${{ steps.buildx.outputs.name }} builder: ${{ steps.buildx.outputs.name }}
# it uses github cache API for faster builds: # it uses github cache API for faster builds:
# https://github.com/crazy-max/docker-build-push-action/blob/master/docs/advanced/cache.md#cache-backend-api # https://github.com/crazy-max/docker-build-push-action/blob/master/docs/advanced/cache.md#cache-backend-api
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
# for an approved pull_request, only push pr-specific tags # for an approved pull_request, only push pr-specific tags
push: ${{ inputs.dockerhub-enable }} push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }} tags: buzzerburger/test:latest
labels: ${{ steps.docker_meta.outputs.labels }} # labels: ${{ steps.docker_meta.outputs.labels }}
- -
name: Show image digest name: Show image digest
run: echo ${{ steps.docker_build_and_push.outputs.digest }} run: echo ${{ steps.docker_build_and_push.outputs.digest }}