forked from nipreps/dmriprep
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
name: Docker Build & Push | ||
|
||
on: [push] | ||
|
||
name: Docker | ||
on: [push, pull_request] | ||
jobs: | ||
|
||
build-and-push: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
name: Check out code | ||
|
||
- uses: mr-smithers-excellent/docker-build-push@feature/add-build-args | ||
name: Build & push Docker image | ||
- name: Checkout repo | ||
uses: actions/checkout@v1 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v1 | ||
with: | ||
image: 'nipreps/dmriprep' | ||
registry: 'docker.io' | ||
buildArgs: 'VERSION=1.0,BUILD_DATE=2020-01-08' | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
python-version: '3.7' | ||
- name: Build docker image | ||
run: | | ||
# Get version, update files. | ||
THISVERSION=$( python get_version.py ) | ||
if [[ ${THISVERSION:0:2} == "0+" ]] ; then | ||
echo "WARNING: latest git tag could not be found" | ||
echo "Please, make sure you fetch all tags from upstream with" | ||
echo "the command ``git fetch --tags --verbose`` and push" | ||
echo "them to your fork with ``git push origin --tags``" | ||
fi | ||
# Build docker image | ||
e=1 && for i in {1..5}; do | ||
docker build --rm \ | ||
-t nipreps/dmriprep:latest \ | ||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ | ||
--build-arg VCS_REF=`git rev-parse --short HEAD` \ | ||
--build-arg VERSION="${CIRCLE_TAG:-$THISVERSION}" . \ | ||
&& e=0 && break || sleep 15 | ||
done && [ "$e" -eq "0" ] | ||
- name: Push docker image | ||
if: startsWith(github.event.ref, 'refs/tags') || startsWith(github.event.ref, 'docker/') || github.event.pull_request.merged == true | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker tag nipreps/dmriprep nipreps/dmriprep:${{ github.sha }} | ||
docker push nipreps/dmriprep:$${{ github.sha }} |