Skip to content

Merge pull request #46 from rasools/1-developing-practical-1 #20

Merge pull request #46 from rasools/1-developing-practical-1

Merge pull request #46 from rasools/1-developing-practical-1 #20

Workflow file for this run

name: Build and Push Docker Image to GHCR
on:
push:
branches:
- 1-developing-practical-1
paths:
- 'day_1/practical_1/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Set GHCR image name based on repository
- name: Set GHCR image name
id: set-ghcr
run: |
if [[ "${{ github.repository }}" == "elixir-europe-training/ELIXIR-SCO-spatial-transcriptomics" ]]; then
echo "Using original repo namespace for GHCR"
echo "IMAGE_NAME=elixir-europe-training/elixir-sco-spatial-transcriptomics" >> $GITHUB_ENV
else
echo "Using fork owner's namespace for GHCR"
echo "IMAGE_NAME=${{ github.actor }}/elixir-sco-spatial-transcriptomics" >> $GITHUB_ENV
fi
shell: bash
# Step 2: Checkout the repository code
- name: Checkout code
uses: actions/checkout@v4
# Step 3: Set up Docker Buildx (enables multi-platform builds)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Step 4: Log in to GitHub Container Registry (GHCR)
- name: Log in to GHCR
run: |
echo "Logging into GHCR"
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
shell: bash
# Step 5: Build and push Docker image to GHCR
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./day_1/practical_1
file: ./day_1/practical_1/Dockerfile
platforms: linux/amd64
push: true
tags: |
ghcr.io/${{ env.IMAGE_NAME }}:practical_1