-
Notifications
You must be signed in to change notification settings - Fork 2
104 lines (93 loc) · 3.43 KB
/
docker-build.yaml
File metadata and controls
104 lines (93 loc) · 3.43 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
104
name: Docker Build and Push
on:
workflow_call:
inputs:
service:
required: true
type: string
description: "Service name to build"
should-build:
required: true
type: boolean
description: "Whether to build this service"
secrets:
DOCKERHUB_USERNAME:
required: false
DOCKERHUB_TOKEN:
required: false
env:
REGISTRY_GHCR: ghcr.io
IMAGE_PREFIX: nesohq/nesohq-issue-tracker
jobs:
build:
runs-on: ubuntu-latest
if: inputs.should-build
permissions:
contents: read
packages: write
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
- name: 🔧 Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 🔐 Login to registries
uses: ./.github/actions/docker-login
with:
ghcr-token: ${{ secrets.GITHUB_TOKEN }}
ghcr-username: ${{ github.actor }}
# Uncomment to enable Docker Hub
# dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
# dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 🏷️ Extract metadata
id: meta
uses: ./.github/actions/docker-metadata
with:
service: ${{ inputs.service }}
registry: ${{ env.REGISTRY_GHCR }}
image-prefix: ${{ env.IMAGE_PREFIX }}
- name: 🐳 Build and push Docker image (client)
if: inputs.service == 'client'
uses: docker/build-push-action@v5
with:
context: ./${{ inputs.service }}
file: ./${{ inputs.service }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
build-args: |
NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }}
NEXT_PUBLIC_KRAKENS_PROJECT_ID=${{ secrets.NEXT_PUBLIC_KRAKENS_PROJECT_ID }}
- name: 🐳 Build and push Docker image (server)
if: inputs.service == 'server'
uses: docker/build-push-action@v5
with:
context: ./${{ inputs.service }}
file: ./${{ inputs.service }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
build-args: |
GH_CLIENT_ID=${{ secrets.GH_CLIENT_ID }}
GH_CLIENT_SECRET=${{ secrets.GH_CLIENT_SECRET }}
GH_REDIRECT_URI=${{ vars.GH_REDIRECT_URI }}
CORS_ORIGIN=${{ vars.CORS_ORIGIN }}
- name: 📝 Generate image summary
run: |
echo "## 🐳 Docker Image Built" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Service:** ${{ inputs.service }}" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Pull command:**" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "docker pull ${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_PREFIX }}/${{ inputs.service }}:latest" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY