Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ LABEL org.opencontainers.image.licenses="MIT"


# Install system packages:
# curl
RUN apt-get update && apt-get install -y curl
# gnupg
RUN apt-get update && apt-get install -y gnupg
# git
RUN apt-get update && apt-get install -y git
# unzip
RUN apt-get update && apt-get install -y unzip
# build-essential
RUN apt-get update && apt-get install -y build-essential
# libsqlite3-dev
RUN apt-get update && apt-get install -y libsqlite3-dev
RUN apt-get update && apt-get install -y \
curl \
gnupg \
git \
unzip \
build-essential \
libsqlite3-dev \
&& rm -rf /var/lib/apt/lists/*
# duckdb
RUN curl -sL https://install.duckdb.org | sh && \
mkdir -p /usr/local/bin && \
Expand Down
5 changes: 4 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.autoSave": "afterDelay",
"terminal.integrated.env.linux": {
"UV_LINK_MODE": "copy"
}
}
}
},
"postCreateCommand": "uv venv --force && uv sync -v",
"postCreateCommand": "uv venv --force && uv sync -v && if ! git remote | grep origin; then repo=$(basename $(pwd)); git remote add origin https://github.com/EED-Solutions/$repo.git; fi",
"features": {},
"remoteUser": "vscode"
}
95 changes: 86 additions & 9 deletions .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
name: Publish Docker Image to GHCR

on:
push:
branches:
- main
tags:
- 'v*.*.*' # Semantic versioning pattern
pull_request:
# This triggers on any PR, but we filter by source branch in the job
types: [opened, synchronize, reopened]
workflow_dispatch:
# push:
# branches: [main]
# paths:
# - '.devcontainer/Dockerfile'
# - '.github/workflows/publish.yml'

permissions:
contents: read
Expand All @@ -19,15 +22,89 @@ jobs:
steps:
- uses: actions/checkout@v4

# Only continue for PRs if the source branch is dev or release
- name: Check PR source branch
if: github.event_name == 'pull_request'
run: |
echo "PR source branch: ${{ github.head_ref }}"
if [[ "${{ github.head_ref }}" != "dev" && "${{ github.head_ref }}" != "release" ]]; then
echo "Not a PR from dev or release branch. Skipping workflow."
exit 1
fi

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_PAT }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
run: |
IMAGE_NAME=ghcr.io/eed-solutions/eed_docker_python_uv:latest
docker build -t $IMAGE_NAME -f .devcontainer/Dockerfile .
docker push $IMAGE_NAME
IMAGE_NAME=ghcr.io/eed-solutions/eed_docker_python_uv
TAG=latest
SHOULD_BUILD_PUSH=false

echo "GITHUB_EVENT_NAME: $GITHUB_EVENT_NAME"
echo "GITHUB_REF: $GITHUB_REF"
echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF"

# Determine context: PR or push/tag
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
BRANCH_NAME="$GITHUB_HEAD_REF"
REF_TYPE="pr"
elif [[ "$GITHUB_REF" == refs/heads/* ]]; then
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
REF_TYPE="branch"
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
BRANCH_NAME="${GITHUB_REF#refs/tags/}"
REF_TYPE="tag"
else
BRANCH_NAME=""
REF_TYPE=""
fi
echo "REF_TYPE: $REF_TYPE"
echo "BRANCH_NAME: $BRANCH_NAME"

# Determine tag and build indicator based on context
if [[ "$REF_TYPE" == "branch" || "$REF_TYPE" == "pr" ]]; then
case "$BRANCH_NAME" in
"main")
TAG=main
SHOULD_BUILD_PUSH=true
;;
"dev")
TAG=dev
SHOULD_BUILD_PUSH=true
;;
"release")
TAG=release
SHOULD_BUILD_PUSH=true
;;
*)
TAG="$BRANCH_NAME"
;;
esac
elif [[ "$REF_TYPE" == "tag" ]]; then
TAG="$BRANCH_NAME"
if [[ "$BRANCH_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
SHOULD_BUILD_PUSH=true
fi
fi

echo "Determined TAG: $TAG"
echo "SHOULD_BUILD_PUSH: $SHOULD_BUILD_PUSH"

# Build and push the image if indicated
if [[ "$SHOULD_BUILD_PUSH" == "true" ]]; then
docker build -t $IMAGE_NAME:$TAG -f .devcontainer/Dockerfile .
docker push $IMAGE_NAME:$TAG
else
echo "Skipping build and push: not a main/dev/release branch or semantic version tag."
fi

# Push additional 'latest' tag for semantic version tags
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
docker tag $IMAGE_NAME:$TAG $IMAGE_NAME:latest
docker push $IMAGE_NAME:latest
fi
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@

## Github actions

Workflows are centraly hosted in EED_Solutions/eed_gha_workflows.
Workflows are centrally hosted in EED_Solutions/eed_gha_workflows.
Please check for more details here.

### Docker Publish Workflow Triggering

The Docker publish workflow (`publish_docker.yml`) is triggered automatically in the following cases:

- **On any push to the `main` branch.**
- **On any tag pushed to the repository that matches semantic versioning (`v*.*.*`).**
- **When a pull request is opened, synchronized, or reopened and the source branch is named `dev` or `release`.**
- Note: The workflow runs for all PRs, but will immediately exit unless the source branch is `dev` or `release`.

This ensures Docker images are only built and published for main releases, version tags, and changes coming from the main development branches.

## Other

Test EED85-machine
Loading