Update publish-docker.yaml

This commit is contained in:
Jaifroid 2021-12-21 12:23:01 +00:00
parent 45b4516352
commit 9d89c8a945

View File

@ -1,6 +1,8 @@
# Workflow to update docker image for moz-extension.kiwix.org (since docker autobuild has been disabled)
# This workflow uses openzim/docker-publish-action@v6
# Documentation: https://github.com/openzim/docker-publish-action#readme
name: Docker
name: Publish Docker container for Mozilla extension
# Controls when the action will run.
on:
@ -8,13 +10,16 @@ on:
release:
types: [ published ]
# Call this for testing from the REST API with '{"version":"{tag}"}'
# 'https://api.github.com/repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches'
# Documentation: https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event
# DEV: You can call this dispatch for testing from the REST API and set input values with
# "inputs": {
# "version": "{tag}"
# }
# API: 'https://api.github.com/repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches'
# Documentation of API: https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event
workflow_dispatch:
inputs:
version:
description: Specific version to build (overrides on-master and tag-pattern)
description: Set any override version number to use (overrides on-master and tag-pattern). If it matches ^[0-9.]+, it will set the appVersion and will be visible to users!
required: false
default: ''
@ -24,6 +29,22 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Modify version in source files
env:
INPUT_VERSION: ${{ github.event.inputs.version }}
TAG_VERSION: ${{ github.event.release.tag_name }}
run: |
# Use the override value by preference
VERSION=${INPUT_VERSION}
# If no valid override input was entered, then use the release tag
if [[ ! $VERSION =~ ^[0-9.]+ ]]; then
VERSION=${TAG_VERSION}
fi
# If Version matches a release pattern, then set the appVersion in the files to be copied to docker container
if [[ $VERSION =~ ^[0-9.]+ ]]; then
sed -i -E "s/appVersion\s*=\s*[^;]+/appVersion = '$VERSION'/" ./service-worker.js
sed -i -E "s/params..appVersion[^=]+?=\s*[^;]+/params['appVersion'] = '$VERSION'/" ./www/js/app.js
fi
- name: Build and push
uses: openzim/docker-publish-action@v6
with:
@ -31,7 +52,7 @@ jobs:
credentials: |
DOCKERIO_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}
DOCKERIO_TOKEN=${{ secrets.DOCKERHUB_PASSWORD }}
tag-pattern: /^v([0-9.]+).*$/
tag-pattern: /^[0-9]([0-9.]+).*$/
latest-on-tag: true
dockerfile: docker/dockerfile-moz-extension.pwa
restrict-to: kiwix/kiwix-js