frappe_docker/.github/workflows/docker-build.yml
Digikwal 2d3d24ef0e
ci: refactor Docker build to trigger on release only
- Replaces workflow_run trigger with release.published
- Builds Docker image only when semantic-release publishes a new tag
- Tags image with immutable version and either :latest or :dev based on stability
- Removes unnecessary artifact dependencies and fallback tag logic
2025-06-26 17:47:22 +02:00

52 lines
1.6 KiB
YAML

name: Digikwal stable
on:
release:
types: [published]
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PAT }}
- name: Setup enviroment variables
run: |
export APPS_JSON_BASE64=$(base64 < ./apps.json | tr -d '\n')
echo "APPS_JSON_BASE64=$APPS_JSON_BASE64" >> $GITHUB_ENV
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
- name: Build Docker image
run: |
docker build \
--build-arg FRAPPE_PATH=https://github.com/frappe/frappe \
--build-arg FRAPPE_BRANCH=version-15 \
--build-arg APPS_JSON_BASE64=${{ env.APPS_JSON_BASE64 }} \
--tag digikwal/erpnext:${{ env.TAG_NAME }} \
--file images/layered/Containerfile .
- name: Push Docker image and tags
env:
DOCKER_IMAGE: digikwal/erpnext
run: |
echo "Using immutable tag: $TAG_NAME"
docker push ${DOCKER_IMAGE}:${TAG_NAME}
if [[ "$TAG_NAME" == *"-"* ]]; then
echo "Detected prerelease. Tagging as dev..."
docker tag ${DOCKER_IMAGE}:${TAG_NAME} ${DOCKER_IMAGE}:dev
docker push ${DOCKER_IMAGE}:dev
else
echo "Detected stable release. Tagging as latest..."
docker tag ${DOCKER_IMAGE}:${TAG_NAME} ${DOCKER_IMAGE}:latest
docker push ${DOCKER_IMAGE}:latest
fi