Skip to content

Pipeline

Pipeline #75

Workflow file for this run

name: Pipeline
on:
workflow_dispatch:
inputs:
SW_VERSION:
description: 'Shopware Version'
required: true
default: '6.5.7.1'
type: choice
options:
- "5.7.18"
- "6.5.0.0"
- "6.5.7.1"
PHP_VERSION:
description: 'PHP Version'
required: true
type: choice
options:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
default: '8.2'
PSALM_VERSION:
description: 'Psalm Version'
required: true
type: choice
default: '5.15.0'
options:
- "4.7.3"
- "4.8.1"
- "5.7.5"
- "5.15.0"
COMPOSER_VERSION:
description: 'Composer Version'
required: true
default: '2.1'
MYSQL_VERSION:
description: 'MySQL Version'
required: false
type: choice
options:
- ""
- "5.7"
- "8.0"
default: '5.7'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set outputs
shell: bash
id: vars
run: |
SW_VERSION=$(echo "${{inputs.SW_VERSION}}" | sed -e "s/^v//")
echo "DOCKER_TAG=${{inputs.SW_VERSION}}-${{inputs.PHP_VERSION}}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "DOCKER_MAIN_TAG=${{inputs.SW_VERSION}}-${{inputs.PHP_VERSION}}" >> $GITHUB_OUTPUT
echo "DOCKER_IMAGE=forestsoft/shopware" >> $GITHUB_OUTPUT
echo "SW_MAJOR=${SW_VERSION:0:1}" >> $GITHUB_OUTPUT
if [ "${SW_VERSION:0:1}" == "6" ]; then
echo "REMOTE_REPO=https://github.com/shopware/production.git" >> $GITHUB_OUTPUT
else
echo "REMOTE_REPO=https://github.com/shopware5/shopware.git" >> $GITHUB_OUTPUT
fi
echo "SW_MAJOR=${SW_VERSION:0:1}" >> $GITHUB_OUTPUT
- name: Set up Docker Context for Buildx
shell: bash
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
endpoint: builders
- name: Inspect builder
shell: bash
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ steps.vars.outputs.DOCKER_IMAGE }}:${{ steps.vars.outputs.DOCKER_MAIN_TAG }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
push: true
build-args: |
SW_VERSION=${{inputs.SW_VERSION}}
PSALM_VERSION=${{inputs.PSALM_VERSION}}
SW_MAJOR=${{ steps.vars.outputs.SW_MAJOR }}
REMOTE_REPO=${{ steps.vars.outputs.REMOTE_REPO }}
COMPOSER_VERSION=${{inputs.COMPOSER_VERSION}}
PHP_VERSION=${{inputs.PHP_VERSION}}
cache-from: |
${{ steps.vars.outputs.DOCKER_IMAGE }}:${{ steps.vars.outputs.DOCKER_MAIN_TAG }}
tags: |
${{ steps.vars.outputs.DOCKER_IMAGE }}:${{ steps.vars.outputs.DOCKER_TAG }}
labels: ${{ steps.meta.outputs.labels }}
build_database:
runs-on: ubuntu-latest
if: ${{ inputs.MYSQL_VERSION != '' }}
steps:
- uses: actions/checkout@v3
- name: Set outputs
shell: bash
id: vars
run: |
SW_VERSION="${{inputs.SW_VERSION}}"
echo "DOCKER_TAG=${{inputs.SW_VERSION}}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "DOCKER_MAIN_TAG=${{inputs.SW_VERSION}}" >> $GITHUB_OUTPUT
echo "DOCKER_IMAGE=forestsoft/shopware_database" >> $GITHUB_OUTPUT
echo "SW_MAJOR=${SW_VERSION:0:1}" >> $GITHUB_OUTPUT
- name: Set up Docker Context for Buildx
shell: bash
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
endpoint: builders
- name: Inspect builder
shell: bash
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ steps.vars.outputs.DOCKER_IMAGE }}:${{ steps.vars.outputs.DOCKER_MAIN_TAG }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: ./build/database/
file: ./build/database/Dockerfile
push: true
build-args: |
SW_VERSION=${{inputs.SW_VERSION}}
SW_MAJOR=${{ steps.vars.outputs.SW_MAJOR }}
VERSION=${{inputs.MYSQL_VERSION}}
cache-from: |
${{ steps.vars.outputs.DOCKER_IMAGE }}:${{ steps.vars.outputs.DOCKER_MAIN_TAG }}
tags: |
${{ steps.vars.outputs.DOCKER_IMAGE }}:${{ steps.vars.outputs.DOCKER_TAG }}
labels: ${{ steps.meta.outputs.labels }}