CI to Docker Hub #141
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 to Docker Hub | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
mediawiki_version: ['1.31'] | |
php_version: ['7.4'] | |
target_repository: ['mediawiki', 'mediawiki-ci'] | |
include: | |
# set global default php | |
- php_default: '7.4' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Docker setup | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
driver-opts: network=host | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache/${{ matrix.mediawiki_version }}/${{ matrix.database_type }} | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
# Env setup | |
- name: Retrieve MediaWiki version | |
run: | | |
source ./helpers.sh | |
echo "MEDIAWIKI_FULL_VERSION=$(mediawiki_version ${{matrix.mediawiki_version}})" >> $GITHUB_ENV | |
- name: generate tags for image | |
run: | | |
source ./helpers.sh | |
echo "TAGS=$(generate_tags gesinn/${{ matrix.target_repository }} ${{env.MEDIAWIKI_FULL_VERSION}} ${{matrix.mediawiki_version}} ${{matrix.php_version}} ${{matrix.php_default}})" >> $GITHUB_ENV | |
# Image build | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
network: host | |
allow: network.host | |
build-args: | | |
MEDIAWIKI_VERSION=${{ env.MEDIAWIKI_FULL_VERSION }} | |
PHP_VERSION=${{ matrix.php_version }} | |
builder: ${{ steps.buildx.outputs.name }} | |
push: true | |
tags: ${{ env.TAGS }} | |
target: ${{ matrix.target_repository }} | |
cache-from: type=local,src=/tmp/.buildx-cache/${{ matrix.mediawiki_version }}/${{ matrix.database_type }} | |
cache-to: type=local,dest=/tmp/.buildx-cache/${{ matrix.mediawiki_version }}/${{ matrix.database_type }} | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |