Skip to content

Commit 3427d3a

Browse files
committed
Refactor
1 parent e43d186 commit 3427d3a

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

.docker/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,7 @@ RUN chmod +x /entrypoint.sh
8787
# Expose only the web server port
8888
EXPOSE 80 8025
8989

90+
LABEL org.opencontainers.image.description="Demo Docker image for showcasing the Sylius Mollie Plugin integration"
91+
9092
# Start all services using Supervisor
9193
ENTRYPOINT ["/entrypoint.sh"]
Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
name: Build and Publish Demo Image
1+
name: Build and Push Docker Image
22

33
on:
44
push:
55
tags:
66
- '*'
77

8-
workflow_dispatch: ~
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: 'Tag version (e.g. 2.0.0)'
12+
required: true
913

1014
jobs:
1115
build:
@@ -21,7 +25,7 @@ jobs:
2125
uses: actions/checkout@v3
2226

2327
- name: Set up Docker Buildx
24-
uses: docker/setup-buildx-action@v2
28+
uses: docker/setup-buildx-action@v3
2529

2630
- name: Log in to GitHub Container Registry
2731
uses: docker/login-action@v3
@@ -30,28 +34,35 @@ jobs:
3034
username: ${{ github.actor }}
3135
password: ${{ secrets.GITHUB_TOKEN }}
3236

33-
- name: Extract version info
34-
id: version
37+
- name: Normalize repository name (lowercase)
38+
run: |
39+
echo "REPO_LOWER=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
40+
41+
- name: Set custom tag for manual run
3542
run: |
3643
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
37-
git fetch --tags
38-
TAG_NAME=$(git describe --tags "$(git rev-list --tags --max-count=1)")
44+
echo "CUSTOM_TAG=type=raw,value=${{ github.event.inputs.version }}" >> $GITHUB_ENV
3945
else
40-
TAG_NAME="${GITHUB_REF#refs/tags/}"
46+
echo "CUSTOM_TAG=" >> $GITHUB_ENV
4147
fi
42-
43-
MAJOR_MINOR=$(echo "$TAG_NAME" | cut -d. -f1,2)
44-
45-
echo "Using tag: $TAG_NAME"
46-
echo "TAG=$TAG_NAME" >> $GITHUB_ENV
47-
echo "MAJOR_MINOR=$MAJOR_MINOR" >> $GITHUB_ENV
48+
49+
- name: Docker meta
50+
id: meta
51+
uses: docker/metadata-action@v5
52+
with:
53+
images: |
54+
ghcr.io/${{ env.REPO_LOWER }}
55+
tags: |
56+
${{ env.CUSTOM_TAG }}
57+
type=semver,pattern={{version}}
58+
type=semver,pattern={{major}}.{{minor}}
59+
flavor: |
60+
latest=false
4861
4962
- name: Build and push Docker image
50-
uses: docker/build-push-action@v2
63+
uses: docker/build-push-action@v6
5164
with:
5265
context: .
66+
file: .docker/Dockerfile
5367
push: true
54-
tags: |
55-
ghcr.io/${{ github.repository_owner }}/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]'):${{ env.TAG }}
56-
ghcr.io/${{ github.repository_owner }}/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]'):${{ env.MAJOR_MINOR }}
57-
68+
tags: ${{ steps.meta.outputs.tags }}

0 commit comments

Comments
 (0)