|
| 1 | +name: publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + publish: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + env: |
| 12 | + IMAGE_BASE: behance/docker-php |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + # Variant distributions all have semantic versions + PHP version + suffix (ex. 3.2.1-alpine) |
| 16 | + props: |
| 17 | + - Dockerfile: Dockerfile-7.4-alpine |
| 18 | + version: "7.4" |
| 19 | + suffix: alpine |
| 20 | + platforms: linux/amd64 |
| 21 | + - Dockerfile: Dockerfile-7.4 |
| 22 | + version: "7.4" |
| 23 | + platforms: linux/amd64,linux/arm64 |
| 24 | + - Dockerfile: Dockerfile-8.0 |
| 25 | + version: "8.0" |
| 26 | + platforms: linux/amd64,linux/arm64 |
| 27 | + steps: |
| 28 | + - |
| 29 | + name: Checkout |
| 30 | + uses: actions/checkout@v2 |
| 31 | + - |
| 32 | + name: Add tag suffix if one exists |
| 33 | + if: matrix.props.suffix |
| 34 | + run: | |
| 35 | + echo TAG_SUFFIX="-${{ matrix.props.suffix }}" >> $GITHUB_ENV |
| 36 | + - |
| 37 | + name: Docker meta |
| 38 | + id: meta |
| 39 | + if: github.event_name != 'pull_request' |
| 40 | + uses: docker/metadata-action@v3 |
| 41 | + with: |
| 42 | + images: ${{ env.IMAGE_BASE }} |
| 43 | + tags: | |
| 44 | + type=raw,priority=100,value=${{ matrix.props.version }} |
| 45 | + type=semver,priority=200,prefix=${{ matrix.props.version }}-,pattern={{major}} |
| 46 | + type=semver,priority=300,prefix=${{ matrix.props.version }}-,pattern={{major}}.{{minor}} |
| 47 | + type=semver,priority=400,prefix=${{ matrix.props.version }}-,pattern={{major}}.{{minor}}.{{patch}} |
| 48 | + flavor: | |
| 49 | + latest=auto |
| 50 | + suffix=${{ env.TAG_SUFFIX }} |
| 51 | + - |
| 52 | + name: Set up QEMU |
| 53 | + uses: docker/setup-qemu-action@v1 |
| 54 | + - |
| 55 | + name: Set up Docker Buildx |
| 56 | + uses: docker/setup-buildx-action@v1 |
| 57 | + - |
| 58 | + name: Login to DockerHub |
| 59 | + if: github.event_name != 'pull_request' |
| 60 | + uses: docker/login-action@v1 |
| 61 | + with: |
| 62 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 63 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 64 | + - |
| 65 | + name: Build + push |
| 66 | + uses: docker/build-push-action@v2 |
| 67 | + with: |
| 68 | + context: . |
| 69 | + platforms: ${{ matrix.props.platforms }} |
| 70 | + file: ${{ matrix.props.Dockerfile }} |
| 71 | + tags: ${{ steps.meta.outputs.tags }} |
| 72 | + push: ${{ github.event_name != 'pull_request' }} |
0 commit comments