Skip to content

Merge pull request #67 from kikkomep/fix/deployment-settings #211

Merge pull request #67 from kikkomep/fix/deployment-settings

Merge pull request #67 from kikkomep/fix/deployment-settings #211

Workflow file for this run

---
name: 'Docker Pipeline'
on:
push:
branches:
- '**'
tags:
- '*.*.*'
pull_request:
env:
TERM: xterm
# enable Docker push only if the required secrets are defined
ENABLE_DOCKER_PUSH: ${{ secrets.DOCKERHUB_USER != null && secrets.DOCKERHUB_TOKEN != null }}
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# Set Docker image
- name: Set up Docker repository
run: echo "DOCKERHUB_REPO=$( if [[ -n $USER_REPO ]]; then echo $USER_REPO; else echo $GITHUB_REPOSITORY; fi )" >> $GITHUB_ENV
env:
USER_REPO: ${{ secrets.DOCKERHUB_REPO }}
- name: Set software version
run: |
sw_version=$(jq -r ".version" package.json)
ref_name=${{ github.ref_name }}
if [[ ${ref_name} == 'develop' ]]; then sw_version="${sw_version}-dev"; fi
echo "SOFTWARE_VERSION=${sw_version}" >> $GITHUB_ENV
sw_version_tag=false
if [[ "${ref_name}" == "master" || "${ref_name}" == "develop" ]]; then sw_version_tag=true; fi
echo "ENABLE_SOFTWARE_VERSION_TAG=${sw_version_tag}" >> $GITHUB_ENV
cp package.json{,.orig} && jq --arg sw_ver "${sw_version}.build${{ github.run_number }}" '.version = $sw_ver' package.json.orig > package.json
# Extract Docker metadata
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKERHUB_REPO }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
type=raw,value=${{ env.SOFTWARE_VERSION }},enable=${{env.ENABLE_SOFTWARE_VERSION_TAG}}
type=raw,value=${{ env.SOFTWARE_VERSION}}.build${{ github.run_number }},enable=${{env.ENABLE_SOFTWARE_VERSION_TAG}}
type=sha
labels: |
org.opencontainers.image.software=${{ env.SOFTWARE_VERSION }}.build${{ github.run_number }}
org.opencontainers.image.build=${{ github.run_number }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
# DockerHub Login
- name: Login to DockerHub
uses: docker/login-action@v2
if: ${{ env.ENABLE_DOCKER_PUSH == 'true' }}
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Build and push
- name: Build
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./docker/Dockerfile
platforms: linux/amd64
push: ${{ env.ENABLE_DOCKER_PUSH == 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}