Skip to content

Commit 3d303e7

Browse files
authored
Merge pull request #5 from EED-Solutions/release
Release
2 parents 0a4cc0f + 1b9985a commit 3d303e7

4 files changed

Lines changed: 110 additions & 23 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ LABEL org.opencontainers.image.licenses="MIT"
1414

1515

1616
# Install system packages:
17-
# curl
18-
RUN apt-get update && apt-get install -y curl
19-
# gnupg
20-
RUN apt-get update && apt-get install -y gnupg
21-
# git
22-
RUN apt-get update && apt-get install -y git
23-
# unzip
24-
RUN apt-get update && apt-get install -y unzip
25-
# build-essential
26-
RUN apt-get update && apt-get install -y build-essential
27-
# libsqlite3-dev
28-
RUN apt-get update && apt-get install -y libsqlite3-dev
17+
RUN apt-get update && apt-get install -y \
18+
curl \
19+
gnupg \
20+
git \
21+
unzip \
22+
build-essential \
23+
libsqlite3-dev \
24+
&& rm -rf /var/lib/apt/lists/*
2925
# duckdb
3026
RUN curl -sL https://install.duckdb.org | sh && \
3127
mkdir -p /usr/local/bin && \

.devcontainer/devcontainer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323
"files.insertFinalNewline": true,
2424
"files.trimFinalNewlines": true,
2525
"files.autoSave": "afterDelay",
26+
"terminal.integrated.env.linux": {
27+
"UV_LINK_MODE": "copy"
28+
}
2629
}
2730
}
2831
},
29-
"postCreateCommand": "uv venv --force && uv sync -v",
32+
"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",
3033
"features": {},
3134
"remoteUser": "vscode"
3235
}
Lines changed: 86 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
name: Publish Docker Image to GHCR
22

33
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*.*.*' # Semantic versioning pattern
9+
pull_request:
10+
# This triggers on any PR, but we filter by source branch in the job
11+
types: [opened, synchronize, reopened]
412
workflow_dispatch:
5-
# push:
6-
# branches: [main]
7-
# paths:
8-
# - '.devcontainer/Dockerfile'
9-
# - '.github/workflows/publish.yml'
1013

1114
permissions:
1215
contents: read
@@ -19,15 +22,89 @@ jobs:
1922
steps:
2023
- uses: actions/checkout@v4
2124

25+
# Only continue for PRs if the source branch is dev or release
26+
- name: Check PR source branch
27+
if: github.event_name == 'pull_request'
28+
run: |
29+
echo "PR source branch: ${{ github.head_ref }}"
30+
if [[ "${{ github.head_ref }}" != "dev" && "${{ github.head_ref }}" != "release" ]]; then
31+
echo "Not a PR from dev or release branch. Skipping workflow."
32+
exit 1
33+
fi
34+
2235
- name: Log in to GHCR
2336
uses: docker/login-action@v3
2437
with:
2538
registry: ghcr.io
2639
username: ${{ github.actor }}
27-
password: ${{ secrets.GH_PAT }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
2841

2942
- name: Build and push Docker image
3043
run: |
31-
IMAGE_NAME=ghcr.io/eed-solutions/eed_docker_python_uv:latest
32-
docker build -t $IMAGE_NAME -f .devcontainer/Dockerfile .
33-
docker push $IMAGE_NAME
44+
IMAGE_NAME=ghcr.io/eed-solutions/eed_docker_python_uv
45+
TAG=latest
46+
SHOULD_BUILD_PUSH=false
47+
48+
echo "GITHUB_EVENT_NAME: $GITHUB_EVENT_NAME"
49+
echo "GITHUB_REF: $GITHUB_REF"
50+
echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF"
51+
52+
# Determine context: PR or push/tag
53+
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
54+
BRANCH_NAME="$GITHUB_HEAD_REF"
55+
REF_TYPE="pr"
56+
elif [[ "$GITHUB_REF" == refs/heads/* ]]; then
57+
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
58+
REF_TYPE="branch"
59+
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
60+
BRANCH_NAME="${GITHUB_REF#refs/tags/}"
61+
REF_TYPE="tag"
62+
else
63+
BRANCH_NAME=""
64+
REF_TYPE=""
65+
fi
66+
echo "REF_TYPE: $REF_TYPE"
67+
echo "BRANCH_NAME: $BRANCH_NAME"
68+
69+
# Determine tag and build indicator based on context
70+
if [[ "$REF_TYPE" == "branch" || "$REF_TYPE" == "pr" ]]; then
71+
case "$BRANCH_NAME" in
72+
"main")
73+
TAG=main
74+
SHOULD_BUILD_PUSH=true
75+
;;
76+
"dev")
77+
TAG=dev
78+
SHOULD_BUILD_PUSH=true
79+
;;
80+
"release")
81+
TAG=release
82+
SHOULD_BUILD_PUSH=true
83+
;;
84+
*)
85+
TAG="$BRANCH_NAME"
86+
;;
87+
esac
88+
elif [[ "$REF_TYPE" == "tag" ]]; then
89+
TAG="$BRANCH_NAME"
90+
if [[ "$BRANCH_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
91+
SHOULD_BUILD_PUSH=true
92+
fi
93+
fi
94+
95+
echo "Determined TAG: $TAG"
96+
echo "SHOULD_BUILD_PUSH: $SHOULD_BUILD_PUSH"
97+
98+
# Build and push the image if indicated
99+
if [[ "$SHOULD_BUILD_PUSH" == "true" ]]; then
100+
docker build -t $IMAGE_NAME:$TAG -f .devcontainer/Dockerfile .
101+
docker push $IMAGE_NAME:$TAG
102+
else
103+
echo "Skipping build and push: not a main/dev/release branch or semantic version tag."
104+
fi
105+
106+
# Push additional 'latest' tag for semantic version tags
107+
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
108+
docker tag $IMAGE_NAME:$TAG $IMAGE_NAME:latest
109+
docker push $IMAGE_NAME:latest
110+
fi

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@
77
88
## Github actions
99
10-
Workflows are centraly hosted in EED_Solutions/eed_gha_workflows.
10+
Workflows are centrally hosted in EED_Solutions/eed_gha_workflows.
1111
Please check for more details here.
1212
13+
### Docker Publish Workflow Triggering
14+
15+
The Docker publish workflow (`publish_docker.yml`) is triggered automatically in the following cases:
16+
17+
- **On any push to the `main` branch.**
18+
- **On any tag pushed to the repository that matches semantic versioning (`v*.*.*`).**
19+
- **When a pull request is opened, synchronized, or reopened and the source branch is named `dev` or `release`.**
20+
- Note: The workflow runs for all PRs, but will immediately exit unless the source branch is `dev` or `release`.
21+
22+
This ensures Docker images are only built and published for main releases, version tags, and changes coming from the main development branches.
23+
1324
## Other
1425
1526
Test EED85-machine

0 commit comments

Comments
 (0)