Skip to content

Publish OCR-D Manager #103

Publish OCR-D Manager

Publish OCR-D Manager #103

Workflow file for this run

name: Publish OCR-D Manager
on:
workflow_dispatch:
inputs:
checkout-ref:
description: The branch, tag or SHA to checkout. Otherwise, uses the default branch.
image-tag:
description: Tag name of Docker image
default: 'latest'
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout without input reference (default)
uses: actions/checkout@v3
if: github.event.inputs.checkout-ref == ''
- name: Checkout input reference ${{ github.event.inputs.checkout-ref }}
uses: actions/checkout@v3
if: github.event.inputs.checkout-ref != ''
with:
ref: ${{ github.event.inputs.checkout-ref }}
- name: Determine environment variables
run: |
date -u +"build_date=%Y-%m-%dT%H:%M:%SZ" >> $GITHUB_ENV
LOCAL_VSC_REF=`git rev-parse --short HEAD`
echo "vcs_ref=$LOCAL_VSC_REF" >> $GITHUB_ENV
echo "cache_key=${{ github.event.inputs.image-tag }}-$LOCAL_VSC_REF" >> $GITHUB_ENV # (input image-tag - vcs_ref)
echo "$LOCAL_VSC_REF" > /tmp/${{ github.event.inputs.image-tag }}-vcs-ref # temporary file to fill cache
- name: Get cache key "${{ env.cache_key }}"
uses: actions/cache/restore@v3
id: cache
with:
path: /tmp/${{ github.event.inputs.image-tag }}-vcs-ref
key: ${{ env.cache_key }}
lookup-only: true
- # Activate cache export feature to reduce build time of images
name: Set up Docker Buildx
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build the OCR-D Manager image "${{ env.IMAGE_NAME }}:${{ github.event.inputs.image-tag }}" and deploy to GitHub Container Repository
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ env.IMAGE_NAME }}:${{ github.event.inputs.image-tag }}
build-args: |
BUILD_DATE=${{ env.build_date }}
VCS_REF=${{ env.vcs_ref }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Save cache key "${{ env.cache_key }}"
uses: actions/cache/save@v3
if: steps.cache.outputs.cache-hit != 'true'
with:
path: /tmp/${{ github.event.inputs.image-tag }}-vcs-ref
key: ${{ env.cache_key }}