Skip to content

Build and Push to Docker Hub #9

Build and Push to Docker Hub

Build and Push to Docker Hub #9

Workflow file for this run

name: Build and Push to Docker Hub
on:
push:
tags: [ "*" ]
jobs:
docker:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- { php: "7.1.33", os: "3.10" }
- { php: "7.2.34", os: "3.12" }
- { php: "7.3.33", os: "3.14" }
- { php: "7.4.22", os: "3.14" }
- { php: "7.4.33", os: "3.16" }
- { php: "8.0.19", os: "3.14" }
- { php: "8.0.30", os: "3.16" }
- { php: "8.1.16", os: "3.16" }
- { php: "8.1.27", os: "3.18" }
- { php: "8.2.3", os: "3.16" }
- { php: "8.2.14", os: "3.18" }
- { php: "8.3.1", os: "3.18" }
steps:
# Use metadata action to get `major.minor` PHP version
- name: Get base PHP Version
id: phpver
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}
flavor: 'latest=false'
tags: 'type=semver,pattern={{major}}.{{minor}},value=${{ matrix.php }}'
# Compute tags for our patch version to go with
- name: Calculate Tags
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}
flavor: 'latest=false'
tags: |
type=semver,pattern=${{ matrix.php }}-{{version}}
type=semver,pattern=${{ matrix.php }}-{{version}}-alpine${{ matrix.os }}
type=semver,pattern=${{ matrix.php }}-{{major}}.{{minor}}.x
type=semver,pattern=${{ matrix.php }}-{{major}}.{{minor}}.x-alpine${{ matrix.os }}
type=semver,pattern=${{ matrix.php }}-{{major}}.x
type=semver,pattern=${{ matrix.php }}-{{major}}.x-alpine${{ matrix.os }}
type=raw,value=${{ matrix.php }}
type=raw,value=${{ matrix.php }}-alpine${{ matrix.os }}
type=semver,pattern=${{ steps.phpver.outputs.version }}-{{version}}
type=semver,pattern=${{ steps.phpver.outputs.version }}-{{version}}-alpine${{ matrix.os }}
type=semver,pattern=${{ steps.phpver.outputs.version }}-{{major}}.{{minor}}.x
type=semver,pattern=${{ steps.phpver.outputs.version }}-{{major}}.{{minor}}.x-alpine${{ matrix.os }}
type=semver,pattern=${{ steps.phpver.outputs.version }}-{{major}}.x
type=semver,pattern=${{ steps.phpver.outputs.version }}-{{major}}.x-alpine${{ matrix.os }}
type=raw,value=${{ steps.phpver.outputs.version }}
type=raw,value=${{ steps.phpver.outputs.version }}-alpine${{ matrix.os }}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: build
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
PHP_VER=${{ matrix.php }}
OS_VER=${{ matrix.os }}