Refactor Docker setup #315
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: CI/CD | |
on: | |
push: | |
pull_request: | |
env: | |
COMPOSER_DISABLE_XDEBUG_WARN: "1" | |
jobs: | |
build: | |
name: Build and test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.2' | |
extensions: json | |
tools: composer | |
- run: composer update | |
- run: | | |
composer validate | |
./vendor/bin/phpcs -s . | |
./bin/console lint:twig ./templates | |
./bin/console lint:yaml ./config | |
./vendor/bin/minus-x check . | |
./bin/phpunit --exclude-group=integration | |
build_image: | |
name: Build Docker image | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build image | |
id: docker_build | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: docker/Dockerfile | |
target: production | |
tags: wikimedia/copypatrol:latest | |
outputs: type=docker,dest=/tmp/copypatrol-production.image.tar | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
- name: Upload Docker image to artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: image-production | |
path: /tmp/copypatrol-production.image.tar | |
analysis: | |
name: Analyze Docker images | |
runs-on: ubuntu-latest | |
needs: build_image | |
steps: | |
- name: Download Docker image from artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: image-production | |
path: /tmp | |
- name: Load image | |
run: | | |
docker load --input /tmp/copypatrol-production.image.tar | |
docker image ls -a | |
- name: Dive | |
uses: MaxymVlasov/[email protected] | |
with: | |
image: wikimedia/copypatrol:latest | |
github-token: ${{ secrets.GITHUB_TOKEN }} |