No longer rely on this repos tags to match tesseract tags for docker #5
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: Docker | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
paths: | |
- 'docker/Dockerfile' | |
- '.github/workflows/docker.yml' | |
release: | |
types: | |
- released | |
jobs: | |
ci: | |
name: ${{ matrix.distro }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
distro: [focal, jammy] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
PUSH_DOCKER_IMAGE: ${{ github.ref == 'refs/heads/master' || github.event_name == 'release' }} | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract Docker meta-information | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
flavor: | | |
latest=false | |
prefix= | |
suffix= | |
tags: | | |
type=ref,event=branch,prefix=${{ matrix.distro }}- | |
type=raw,event=pr,prefix=${{ matrix.distro }}-,value=master | |
type=semver,pattern={{major}}.{{minor}},prefix=${{ matrix.distro }}- | |
# Set TAG environment variable to specify right version of tesseract docker image to pull | |
- name: Set TAG environment variable | |
run: | | |
# Check if the current workflow run was triggered by a tag. | |
if [[ "${{ github.ref_type }}" == "tag" ]]; then | |
# If it's a tag event, set the TAG to the latest tagged version of tesseract | |
echo "TAG=${{ matrix.distro }}-0.21" >> $GITHUB_ENV | |
else | |
# If it's not a tag event (e.g., a push to a branch or a PR), set the TAG to distro-master. | |
echo "TAG=${{ matrix.distro }}-master" >> $GITHUB_ENV | |
fi | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: docker/Dockerfile # filepath to Dockerfile in this repo | |
build-args: TAG=${{ env.TAG }} # Argument for Dockerfile to specify tag of parent container | |
push: ${{ env.PUSH_DOCKER_IMAGE }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |