Update docker.yml
This commit is contained in:
@@ -70,6 +70,7 @@ on:
|
||||
description: Docker Hub token
|
||||
required: false
|
||||
|
||||
|
||||
jobs:
|
||||
|
||||
laravel-tests:
|
||||
@@ -85,81 +86,70 @@ jobs:
|
||||
cd app/code
|
||||
composer install
|
||||
php artisan test
|
||||
|
||||
builtandtestimages:
|
||||
|
||||
|
||||
build-and-push-images:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
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
|
||||
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
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
-
|
||||
name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
if: ${{ inputs.dockerhub-enable }}
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
# -
|
||||
# name: Login to GHCR
|
||||
# if: github.event_name != 'pull_request'
|
||||
# uses: docker/login-action@v1
|
||||
# with:
|
||||
# registry: ghcr.io
|
||||
# username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
# password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
username: ${{ inputs.dockerhub-username }}
|
||||
password: ${{ secrets.dockerhub-token }}
|
||||
-
|
||||
name: Login to GHCR
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: Docker meta
|
||||
id: docker_meta
|
||||
uses: docker/metadata-action@v3.6.2
|
||||
with:
|
||||
# list of Docker images to use as base name for tags
|
||||
images: |
|
||||
buzzerburger/test
|
||||
ghcr.io/buzzerburger/test
|
||||
images: ${{ inputs.image-names }}
|
||||
flavor: |
|
||||
latest=false
|
||||
tags: |
|
||||
type=raw,value=latest
|
||||
|
||||
# -
|
||||
# # this will build the images, once per platform,
|
||||
# # then push to both Docker Hub and GHCR
|
||||
# name: 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
|
||||
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,
|
||||
# then push to both Docker Hub and GHCR
|
||||
name: Docker Build and Push
|
||||
id: docker_build_and_push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: app
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: ${{ inputs.platforms }}
|
||||
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-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
|
||||
|
||||
push: ${{ inputs.dockerhub-enable }}
|
||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||
-
|
||||
name: Show image digest
|
||||
run: echo ${{ steps.docker_build_and_push.outputs.digest }}
|
||||
|
||||
Reference in New Issue
Block a user