-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (80 loc) · 2.93 KB
/
docker.yml
File metadata and controls
90 lines (80 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: "Docker Build and Push (PROMCODE Server)"
on:
push:
branches: [main, master]
paths:
- 'promcode-lyo-server/**'
- 'promcode-lyo-server-model/**'
- 'Dockerfile'
- 'docker-compose.yml'
- '.github/workflows/docker.yml'
release:
types: [published]
schedule:
# Weekly rebuild every Thursday at 5:00 AM UTC to get latest base image updates
- cron: '0 5 * * 4'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check build trigger
run: |
if [ "${{ github.event_name }}" = "schedule" ]; then
echo "🔄 This is a scheduled weekly rebuild to update base images"
elif [ "${{ github.event_name }}" = "release" ]; then
echo "🚀 This is a release build"
else
echo "📦 This is a regular build triggered by push"
fi
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# For pushes to master/main branch or scheduled builds, tag as "latest"
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || github.event_name == 'schedule' }}
# For releases, create semantic version tags
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
labels: |
org.opencontainers.image.title=PROMCODE Server
org.opencontainers.image.description=A demonstration server for OSLC toolchain management of PROject Management of COntracted DElivery
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
# For scheduled builds, don't use cache to ensure fresh base images
no-cache: ${{ github.event_name == 'schedule' }}
pull: true
- name: Output image details
run: |
echo "Image has been pushed to:"
echo "${{ steps.meta.outputs.tags }}" | while read -r tag; do
echo " - $tag"
done