Skip to content

fix: env is not accessible from matrix #4

fix: env is not accessible from matrix

fix: env is not accessible from matrix #4

name: Build Container Images
on:
push:
branches:
- master
- build-container # This branch is used to test the container build workflow.
tags:
- v*
jobs:
build-and-push:
name: Build and Push
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: true
matrix:
include:
- container-name: php
base-tag: 7.4-4.33.4
- container-name: nginx
base-tag: 1.25-5.34.2
env:
REGISTRY: ghcr.io
CONTAINER_NAME: ${{ github.repository }}/${{ matrix.container-name }}
BASE_CONTAINER_TAG: ${{ matrix.base-tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Buildx
uses: docker/setup-buildx-action@v2
- name: Log into registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract container metadata
id: meta
uses: docker/metadata-action@v4
with:
images: "${{ env.REGISTRY }}/${{ env.CONTAINER_NAME }}"
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
file: ./containers/${{ matrix.container-name }}/Dockerfile
build-args: |
BASE_TAG=${{ env.BASE_CONTAINER_TAG }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max