Add new ConcreteCMS versions #326
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Docker images | |
on: | |
pull_request: | |
paths: | |
- .github/workflows/build.yml | |
- .github/workflows/generate-matrix | |
- "base/**" | |
- "installed/**" | |
- data/versions.json | |
push: | |
branches: | |
- main | |
tags-ignore: | |
- "**" | |
paths: | |
- .github/workflows/build.yml | |
- .github/workflows/generate-matrix | |
- "base/**" | |
- "installed/**" | |
- data/versions.json | |
repository_dispatch: | |
types: | |
- build | |
- publish | |
jobs: | |
check_envoronment: | |
name: Check environment | |
runs-on: ubuntu-latest | |
outputs: | |
action: ${{ steps.inspect.outputs.action }} | |
steps: | |
- | |
name: Inspect environment | |
id: inspect | |
run: | | |
action=none | |
echo 'action=none' >> $GITHUB_OUTPUT | |
case ${{ github.event_name }} in | |
repository_dispatch) | |
case "${{ github.event.event_type }}" in | |
build) | |
action=build | |
;; | |
publish) | |
action=publish | |
;; | |
*) | |
echo 'Unrecognized event type: ${{ github.event.event_type }}' | |
exit 1 | |
;; | |
esac | |
;; | |
push) | |
case "${{ github.event.head_commit.message }}" in | |
\[skip\ ci\]*) | |
;; | |
*) | |
action=publish | |
;; | |
esac | |
;; | |
pull_request) | |
action=build | |
;; | |
esac | |
echo "action=$action" >> $GITHUB_OUTPUT | |
- | |
name: Print environment info | |
run: | | |
printf 'github.event_name: %s\n' "${{ github.event_name }}" | |
printf 'github.ref: %s\n' "${{ github.ref }}" | |
printf 'Action to be performed: %s\n' "${{ steps.inspect.outputs.action }}" | |
build_base: | |
name: Build base image | |
needs: | |
- check_envoronment | |
runs-on: ubuntu-latest | |
if: needs.check_envoronment.outputs.action != 'none' | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Build | |
run: docker build --force-rm --rm --tag ghcr.io/concrete5-community/docker5:base ./base | |
- | |
name: Save base Docker image | |
if: needs.check_envoronment.outputs.action == 'build' | |
run: docker save ghcr.io/concrete5-community/docker5:base | gzip > /tmp/base-image.tgz | |
- | |
name: Upload artifact | |
if: needs.check_envoronment.outputs.action == 'build' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: base-image | |
path: /tmp/base-image.tgz | |
- | |
name: Login to the Docker container registry | |
if: needs.check_envoronment.outputs.action == 'publish' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Publish image | |
if: needs.check_envoronment.outputs.action == 'publish' | |
run: docker push ghcr.io/concrete5-community/docker5:base | |
generate_matrix: | |
name: Generate matrix | |
runs-on: ubuntu-latest | |
outputs: | |
generated-matrix: ${{ steps.generate-matrix.outputs.generated-matrix }} | |
steps: | |
- | |
name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.2' | |
extensions: none | |
tools: none | |
coverage: none | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Generate matrix | |
id: generate-matrix | |
run: ./.github/workflows/generate-matrix build.yml "$GITHUB_OUTPUT" | |
build: | |
name: Build ${{ matrix.data.image_tag }} | |
runs-on: ubuntu-latest | |
needs: | |
- check_envoronment | |
- build_base | |
- generate_matrix | |
if: needs.check_envoronment.outputs.action != 'none' | |
strategy: | |
matrix: | |
data: ${{ fromJSON(needs.generate_matrix.outputs.generated-matrix) }} | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Download base image | |
if: needs.check_envoronment.outputs.action == 'build' | |
uses: actions/download-artifact@v4 | |
with: | |
name: base-image | |
path: /tmp/ | |
- | |
name: Load base image | |
if: needs.check_envoronment.outputs.action == 'build' | |
run: docker load --input /tmp/base-image.tgz | |
- | |
name: Build with starting point ${{ matrix.data.c5_startingpoint }} | |
run: | | |
docker build \ | |
--build-arg CCM_PHP_VERSION=${{ matrix.data.php_version }} \ | |
--build-arg CCM_COMPOSER_VERSION=${{ matrix.data.composer_version }} \ | |
--build-arg CCM_PHPUNIT_VERSION=${{ matrix.data.phpunit_version }} \ | |
--build-arg CCM_C5_ARCHIVE=${{ matrix.data.c5_archive }} \ | |
--build-arg CCM_STARTING_POINT=${{ matrix.data.c5_startingpoint }} \ | |
--build-arg CCM_PATCH_ENVIRONMENT_ONLY=${{ matrix.data.patch_environment_only }} \ | |
--tag ghcr.io/concrete5-community/docker5:${{ matrix.data.image_tag }} \ | |
./installed | |
for additional_tag in ${{ matrix.data.additional_tags }}; do | |
docker tag ghcr.io/concrete5-community/docker5:${{ matrix.data.image_tag }} ghcr.io/concrete5-community/docker5:$additional_tag | |
done | |
- | |
name: Check that MariaDB works | |
run: docker run --rm --entrypoint='' ghcr.io/concrete5-community/docker5:${{ matrix.data.image_tag }} ccm-service start db | |
- | |
name: Remove base Docker image | |
if: needs.check_envoronment.outputs.action == 'publish' | |
run: docker rmi ghcr.io/concrete5-community/docker5:base || true | |
- | |
name: Login to the Docker container registry | |
if: needs.check_envoronment.outputs.action == 'publish' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Publish image | |
if: needs.check_envoronment.outputs.action == 'publish' | |
run: docker push --all-tags ghcr.io/concrete5-community/docker5 |