-
Notifications
You must be signed in to change notification settings - Fork 2
71 lines (63 loc) · 2.03 KB
/
Copy pathbuild-docker-image.yml
File metadata and controls
71 lines (63 loc) · 2.03 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
name: Container Build and Push
on:
push:
branches:
- "main"
workflow_dispatch:
schedule:
# Do a daily rebuild at 2:00 AM UTC
- cron: '0 2 * * *'
env:
GITHUB_REGISTRY: ghcr.io
jobs:
# Branch push job - builds and pushes to both registries
branch-push:
# This workflow is only for pushing builds from the official repo
if: github.repository_owner == 'chairemobilite'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# Matrix strategy to build both client and server image
strategy:
fail-fast: false
matrix:
include:
- name: client
context: client
dockerfile: client/Dockerfile
- name: server
context: .
dockerfile: serveur/Dockerfile
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Generate Docker tags for branch
id: branch-meta
uses: docker/metadata-action@v6
with:
images: |
${{ env.GITHUB_REGISTRY }}/${{ github.repository }}-${{ matrix.name }}
tags: |
# Tag as latest for main
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
# Include the branch name as a tag
type=ref,event=branch
- name: Build and push ${{ matrix.name }} images
uses: docker/build-push-action@v7
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.branch-meta.outputs.tags }}
labels: ${{ steps.branch-meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.name }}
cache-to: type=gha,mode=max,scope=${{ matrix.name }}