-
Notifications
You must be signed in to change notification settings - Fork 1
103 lines (91 loc) · 3.36 KB
/
docker-build-dpr.yml
File metadata and controls
103 lines (91 loc) · 3.36 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
91
92
93
94
95
96
97
98
99
100
101
102
103
# Build and publish Digital Planning Register container image to ghcr.io
#
# Builds from the upstream tpximpact/digital-planning-register repository.
#
# Triggers on:
# - Manual workflow_dispatch (with optional version tag)
# - Weekly schedule (to pick up upstream updates)
#
# Produces:
# - ghcr.io/[org]/ndx_try_aws_scenarios-dpr:latest
# - ghcr.io/[org]/ndx_try_aws_scenarios-dpr:sha-<commit>
name: Build Digital Planning Register Container
on:
schedule:
# Weekly on Monday at 06:00 UTC
- cron: '0 6 * * 1'
workflow_dispatch:
inputs:
upstream_ref:
description: 'Upstream git ref to build (branch, tag, or commit SHA)'
required: false
default: 'main'
type: string
push_image:
description: 'Push image to registry'
required: false
default: true
type: boolean
env:
REGISTRY: ghcr.io
IMAGE_NAME: co-cddo/ndx_try_aws_scenarios-dpr
UPSTREAM_REPO: tpximpact/digital-planning-register
jobs:
build:
name: Build and Push Container
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Determine upstream ref
id: ref
run: |
REF="${{ github.event.inputs.upstream_ref || 'main' }}"
echo "ref=$REF" >> $GITHUB_OUTPUT
- name: Checkout upstream repository
uses: actions/checkout@v6
with:
repository: ${{ env.UPSTREAM_REPO }}
ref: ${{ steps.ref.outputs.ref }}
- name: Get upstream commit SHA
id: sha
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=raw,value=sha-${{ steps.sha.outputs.sha }}
type=raw,value=upstream-${{ steps.ref.outputs.ref }},enable=${{ steps.ref.outputs.ref != 'main' }}
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
push: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image != 'false') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
- name: Output image details
run: |
echo "## Digital Planning Register Image Built" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Upstream:** ${{ env.UPSTREAM_REPO }}@${{ steps.sha.outputs.sha }}" >> $GITHUB_STEP_SUMMARY
echo "**Registry:** ${{ env.REGISTRY }}" >> $GITHUB_STEP_SUMMARY
echo "**Image:** ${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY