Docker Build and Publish Image (run every day) #238
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: Docker Build and Publish Image (run every day) | |
on: | |
schedule: | |
- cron: "0 4 * * *" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_IMAGE: sybila/ebcsgen | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v2 | |
- name: Setup conda | |
uses: conda-incubator/setup-miniconda@v2 | |
- name: Get latest release tag | |
id: release_version | |
uses: pozetroninc/github-action-get-latest-release@master | |
with: | |
repository: ${{ github.repository }} | |
- name: Look up latest conda eBCSgen release | |
run: echo "::set-output name=latest::$(conda search --channel bioconda eBCSgen | tail -n1 | awk {'print "v"$2'})" | |
id: conda_version | |
- name: Look up docker image | |
id: docker_lookup | |
if: ${{ steps.conda_version.outputs.latest == steps.release_version.outputs.release }} | |
run: echo ::set-output name=exists::$(docker manifest inspect ${DOCKER_IMAGE}:${{ steps.release_version.outputs.release }} > /dev/null ; echo $?) | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build Docker image | |
if: ${{ steps.docker_lookup.outputs.exists != 0 }} | |
run: | | |
docker build \ | |
--tag ${DOCKER_IMAGE}:latest \ | |
--tag ${DOCKER_IMAGE}:${{ steps.release_version.outputs.release }} \ | |
. | |
- name: Publish Docker image | |
# Only deploy if using master on original repo (and not for pull requests or forks) | |
if: ${{ steps.docker_lookup.outputs.exists != 0 && github.repository_owner == 'sybila' && github.ref == 'refs/heads/master' }} | |
run: | | |
docker push --all-tags ${DOCKER_IMAGE} |