Djones slurm #250
Workflow file for this run
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: Publish Docker image | |
# This workflow manages the testing, building, and publishing of docker images | |
# On a pull request to main: | |
# If docker related files are changed, the image is test built and not published | |
# On a push to main (or a new tag is created on master): | |
# The docker image is built and tagged with latest and and / or new tag version | |
on: | |
push: | |
branches: [main] | |
paths: | |
- "app/Dockerfile" | |
- "app/requirements.txt" | |
tags: | |
- "*" | |
pull_request: | |
branches: [main] | |
paths: | |
- "app/Dockerfile" | |
- "app/requirements.txt" | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Prepare | |
id: prep | |
run: | | |
DOCKER_IMAGE=ghcr.io/astrophpeter/blast | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/v} | |
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:latest" | |
else | |
TAGS="${DOCKER_IMAGE}:latest" | |
fi | |
echo ::set-output name=tags::${TAGS} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to ghcr | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
context: ./app | |
file: ./app/Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.prep.outputs.tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |