Skip to content

build-push

build-push #30

Workflow file for this run

name: build-push
on:
push:
branches:
schedule:
- cron: '15 12 * * *'
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
id-token: write
steps:
- uses: 'actions/checkout@v4'
- uses: hadolint/[email protected]
with:
dockerfile: Dockerfile
verbose: true
- name: check valid sh
run: shellcheck **/*.sh
build-push:
needs: [lint]
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ["8.1", "8.2", "8.3"]
drupal-version: ["10.2.x", "10.3.x", "10.4.x-dev", "11.0.x"]
exclude:
- drupal-version: "11.0.x"
php-version: "8.1"
- drupal-version: "11.0.x"
php-version: "8.2"
steps:
- uses: 'actions/checkout@v4'
- name: Extract branch or tag name as docker tag
shell: bash
run: |-
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG=$(echo "${GITHUB_REF#refs/tags/}" | sed 's/[^a-zA-Z0-9._-]//g' | awk '{print substr($0, length($0)-120)}')
else
TAG=$(echo "${GITHUB_REF#refs/heads/}" | sed 's/[^a-zA-Z0-9._-]//g' | awk '{print substr($0, length($0)-120)}')
if [ "$TAG" = "main" ]; then
TAG=""
fi
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
DRUPAL_MAJOR_MINOR=$(echo "${{ matrix.drupal-version }}" | cut -d. -f1,2)
echo "drupal_version=$DRUPAL_MAJOR_MINOR" >> $GITHUB_OUTPUT
id: extract_tag
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Hub Login
uses: docker/login-action@v3
with:
registry: 'docker.io'
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push dockerhub
uses: docker/build-push-action@v6
with:
platforms: |
linux/386
linux/amd64
linux/arm64/v8
linux/arm/v7
build-args: |
PHP_VERSION=${{ matrix.php-version }}
DRUPAL_VERSION=${{ matrix.drupal-version }}
push: true
tags: |
lehighlts/drupal-ci:${{ steps.extract_tag.outputs.drupal_version }}-php${{ matrix.php-version }}${{steps.extract_tag.outputs.tag}}