forked from opendatahub-io/batch-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (75 loc) · 2.71 KB
/
docker.yml
File metadata and controls
88 lines (75 loc) · 2.71 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
name: Docker Build and Push
on:
push:
branches:
- main
tags:
- 'v*.*.*'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- 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
id: meta
run: |
# Get the commit SHA (short version)
COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
echo "commit_sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT
# Get the current timestamp
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "build_date=${BUILD_DATE}" >> $GITHUB_OUTPUT
# Determine the version and tag based on the event
if [[ "${{ github.ref_type }}" == "tag" ]]; then
# For tag pushes, use the tag name as version
VERSION="${{ github.ref_name }}"
TAG="${{ github.ref_name }}"
elif [[ "${{ github.ref_name }}" == "main" ]]; then
# For main branch, use 'latest'
VERSION="main-${COMMIT_SHA}"
TAG="latest"
else
# For PRs and other branches, use 'dev'
VERSION="dev-${COMMIT_SHA}"
TAG="dev"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- name: Build and push Docker images
uses: docker/bake-action@v7
with:
files: docker-bake.hcl
targets: default
push: true
env:
REGISTRY: ghcr.io/llm-d-incubation
COMMIT_SHA: ${{ steps.meta.outputs.commit_sha }}
BUILD_DATE: ${{ steps.meta.outputs.build_date }}
VERSION: ${{ steps.meta.outputs.version }}
TAG: ${{ steps.meta.outputs.tag }}
- name: Output image tags
run: |
echo "Images pushed:"
echo " - ghcr.io/llm-d-incubation/batch-gateway-apiserver:${{ steps.meta.outputs.commit_sha }}"
echo " - ghcr.io/llm-d-incubation/batch-gateway-apiserver:${{ steps.meta.outputs.tag }}"
echo " - ghcr.io/llm-d-incubation/batch-gateway-processor:${{ steps.meta.outputs.commit_sha }}"
echo " - ghcr.io/llm-d-incubation/batch-gateway-processor:${{ steps.meta.outputs.tag }}"