Skip to content

DCAN fork updates

DCAN fork updates #23

Workflow file for this run

name: Docker Image CI
on:
push:
# Publish `main` as Docker `latest` image.
branches:
- main
release:
types: [published]
# Run tests for any PRs.
pull_request:
env:
IMAGE_NAME: mcribs
jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Log into GitHub Container Registry
run: echo "${{ secrets.GH_PACKAGES_TOKEN }}" | docker login https://docker.pkg.github.com -u nipreps-bot --password-stdin
- uses: jpribyl/[email protected]
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME
# - name: Push image to GitHub Container Registry
# if: github.event_name == 'release'
# run: |
# IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# # Change all uppercase to lowercase
# IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# # Strip git ref prefix from version
# VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# # Strip "v" prefix from tag name
# [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# # Use Docker `latest` tag convention
# [ "$VERSION" == "main" ] && VERSION=latest
# echo IMAGE_ID=$IMAGE_ID
# echo VERSION=$VERSION
# docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
# docker push $IMAGE_ID:$VERSION
- name: Log into DockerHub Container Registry
run: echo "${{ secrets.DH_PAT }}" | docker login -u niprepsbot --password-stdin
- name: Push image to DockerHub Container Registry
if: github.event_name == 'release'
run: |
IMAGE_ID=nipreps/${IMAGE_NAME}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION