Create dockerhub_release.yml #79
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: Publish Docker image | |
on: | |
release: | |
types: [published] | |
push: | |
branchs: [master] | |
workflow_dispatch: | |
inputs: | |
ubuntu_version: | |
description: Ubuntu version that is used in the image | |
default: '20.04' | |
ghc_version: | |
descritpion: GHC of the build that is used | |
default: '8.10.2' | |
strip: | |
description: whether to strip symobls from the binaries | |
default: true | |
jobs: | |
# ########################################################################## # | |
# Configure Workflow | |
config: | |
name: Configure Workflow | |
runs-on: ubuntu-latest | |
outputs: | |
ubuntu_version: ${{ steps.settings.outputs.ubuntu_version }} | |
ghc_version: ${{ steps.settings.outputs.ghc_version }} | |
strip: ${{ steps.settings.outputs.strip }} | |
steps: | |
- name: Get input values | |
id: settings | |
run: | | |
if [[ ${{ github.event_name }} = "workflow_dispatch" ]] ; then | |
echo "::set-output name=ubuntu_version::${{ github.event.inputs.ubuntu_version }}" | |
echo "::set-output name=ghc_version::${{ github.event.inputs.ghc_version }}" | |
if [[ "${{ github.event.inputs.strip }}" = "true" ]] ; then | |
echo "::set-output name=strip::1" | |
else | |
echo "::set-output name=strip::0" | |
fi | |
else | |
echo "::set-output name=ubuntu_version::20.04" | |
echo "::set-output name=ghc_version::8.10.2" | |
echo "::set-output name=strip::1" | |
fi | |
# ########################################################################## # | |
# Main | |
main: | |
needs: [config] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Docker meta | |
id: docker_meta | |
uses: crazy-max/ghaction-docker-meta@v1 | |
with: | |
images: ghcr.io/larskuhtz/chainweb-node # list of Docker images to use as base name for tags | |
tag-sha: true # add git short SHA as Docker tag | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
build-args: | | |
GHCVER=${{ needs.config.outputs.ghc_version }} | |
UBUNTUVER=${{ needs.config.outputs.ubuntu_version }} | |
STRIP=${{ needs.config.outputs.strip }} | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: ${{ steps.docker_meta.outputs.labels }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |