Skip to content

Merge pull request #3 from nonanerz/82 #7

Merge pull request #3 from nonanerz/82

Merge pull request #3 from nonanerz/82 #7

Workflow file for this run

name: Create and publish a Docker image
# Cache setup: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md
# Multi push: https://github.com/docker/build-push-action/blob/master/docs/advanced/push-multi-registries.md
on:
push:
branches: ['*']
jobs:
checks-update:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check update has been run
run: |
./update.sh
git diff --quiet
checks-hadolint:
runs-on: ubuntu-latest
permissions:
contents: read
container: hadolint/hadolint:latest-debian
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check hadolint
run: |
hadolint --ignore DL3059 */Dockerfile
checks-shfmt:
runs-on: ubuntu-latest
permissions:
contents: read
container: mvdan/shfmt:latest-alpine
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check shfmt
run: |
shfmt -i 2 -ci -d update.sh
checks-shellcheck:
runs-on: ubuntu-latest
permissions:
contents: read
container: koalaman/shellcheck-alpine:latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check shellcheck
run: |
shellcheck update.sh
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
version: [ '7', '7.3', '7.4', '8', '8.0', '8.1' ]
distro: ['', '-alpine']
debug: ['', '-xdebug']
exclude:
- distro: '-alpine'
debug: '-xdebug'
needs: [checks-hadolint, checks-shfmt, checks-shellcheck, checks-update]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
if: github.ref == 'refs/heads/master'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ekreative/php
tags: |
type=raw,value=${{ matrix.version }}${{ matrix.distro }}${{ matrix.debug }}
flavor: |
latest=${{ toJSON(matrix.version == '8' && matrix.distro == '' && matrix.debug == '' && github.ref == 'refs/heads/master') }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ${{ matrix.version }}${{ matrix.distro }}${{ matrix.debug }}
push: ${{ github.ref == 'refs/heads/master' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max