Skip to content

Port original nf-core training #1866

Port original nf-core training

Port original nf-core training #1866

Workflow file for this run

# Build and push the Docker image for GitHub Codespaces
# - Only pushes if push or release
# - Builds without push for PRs to check the Dockerfile
name: Docker image
on:
pull_request: # Build, don't push
push: { branches: [master] } # Build + push ('latest' tag)
release: { types: [published] } # Build + push (release tag)
workflow_dispatch: # Build + push (custom tag)
inputs:
tag_name:
description: "Docker image tag name"
type: string
required: true
jobs:
build_push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Set tag variable
run: |
if [[ '${{ github.event_name }}' == 'release' ]]; then
echo "IMAGE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
elif [[ '${{ github.event_name }}' == 'workflow_dispatch' ]]; then
echo "IMAGE_TAG=${{ inputs.tag_name }}" >> $GITHUB_ENV
else
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
fi
- name: Check out the repo
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build / push image
uses: docker/build-push-action@v6
with:
file: .devcontainer/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max