Skip to content

increment version

increment version #322

Workflow file for this run

name: Docker
on:
workflow_dispatch:
# Allows manually triggering workflow in GitHub UI on selected branch.
# GitHub doc: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_dispatch.
# GitHub blog demo: https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/.
# For now, disable the Docker deployment step.
push:
# Publish `master` as Docker `ml4h_terra:YYMMDD_hhmmss` image.
branches: [ master ]
# Publish `v1.2.3` tags as releases.
tags:
- v*
#Run tests for any PRs.
#pull_request:
env:
IMAGE_NAME: ml4h_terra
jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: |
./docker/vm_boot_images/build.sh -P
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
# Ensure test job passes before pushing image.
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v2
- name: Build image
run: |
cd docker/terra_image
docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Log into registry
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# By default, use the branch name as the tag.
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# For repo tagging events, use the tag as the Docker image tag.
# Strip "v" prefix from tag name.
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# When the branch is 'master', use Docker date and time tag convention
[ "$VERSION" == "master" ] && VERSION=$(date +"%Y%m%d_%H%M%S")
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION