Update docker.yml

This commit is contained in:
Nobix
2022-04-08 06:28:54 +05:30
committed by GitHub
parent a3d27c9ce1
commit 90c1845354
+37 -47
View File
@@ -70,6 +70,7 @@ on:
description: Docker Hub token description: Docker Hub token
required: false required: false
jobs: jobs:
laravel-tests: laravel-tests:
@@ -86,80 +87,69 @@ jobs:
composer install composer install
php artisan test php artisan test
builtandtestimages:
build-and-push-images:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- -
# we need qemu and buildx so we can build multiple platforms later
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v1 id: qemu
uses: docker/setup-qemu-action@v1.2.0
- -
# BuildKit (used with `docker buildx`) is the best way to build images
name: Set up Docker Buildx name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- -
name: Login to DockerHub name: Login to DockerHub
if: github.event_name != 'pull_request' if: ${{ inputs.dockerhub-enable }}
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
username: ${{ secrets.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: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.GITHUB_TOKEN }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
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: | images: ${{ inputs.image-names }}
buzzerburger/test
ghcr.io/buzzerburger/test
flavor: | flavor: |
latest=false latest=false
tags: | tags: |
type=raw,value=latest type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
type=ref,event=pr,prefix=pr
# - -
# # 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
# name: Docker Build and Push name: Docker Build and Push
# id: docker_build_and_push id: docker_build_and_push
# uses: docker/build-push-action@v2
# with:
# platforms: linux/amd64
# context: app
# target: ${{ inputs.target }}
# file: ${{ inputs.file }}
# builder: ${{ steps.buildx.outputs.name }}
# # 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
# cache-from: type=gha
# cache-to: type=gha,mode=max
# # for an approved pull_request, only push pr-specific tags
# push: ${{ github.event_name != 'pull_request' }}
# tags: buzzerburger/test:latest
# # labels: ${{ steps.docker_meta.outputs.labels }}
- name: Build and push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: app platforms: ${{ inputs.platforms }}
platforms: linux/amd64,linux/arm64 context: ${{ inputs.context }}
target: ${{ inputs.target }}
file: ${{ inputs.file }}
builder: ${{ steps.buildx.outputs.name }}
# 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
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
push: ${{ github.event_name != 'pull_request' }}
tags: buzzerburger/test:latest
# for an approved pull_request, only push pr-specific tags # for an approved pull_request, only push pr-specific tags
push: ${{ inputs.dockerhub-enable }}
tags: ${{ steps.docker_meta.outputs.tags }}
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 }}