Repository navigation
Expand file tree
/
Copy pathagent_server_dockerhub_image.yml
More file actions
111 lines (101 loc) · 3.49 KB
/
Copy pathagent_server_dockerhub_image.yml
File metadata and controls
111 lines (101 loc) · 3.49 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
105
106
107
108
109
110
111
name: Publish agents-server image to Docker Hub
# If you decide to modify the list of triggers for this action, don't forget to also update the
# conditional logic in the derive_build_vars job below.
on:
push:
branches: ['main']
paths:
- 'packages/agents-server/**'
- 'packages/agents-server-ui/**'
- 'packages/agents-runtime/**'
# Allows the workflow to be called by the Changesets workflow
workflow_call:
inputs:
git_ref:
description: 'Git ref to build from (branch name, tag, or commit SHA)'
required: true
type: string
docker_tag:
description: 'Optional Docker Hub tag override (derived from git_ref if omitted)'
required: false
type: string
# Allows the workflow to be triggered manually from the UI
workflow_dispatch:
inputs:
git_ref:
description: 'Git ref to build from (branch name, tag, or commit SHA)'
required: true
type: string
docker_tag:
description: 'Optional Docker Hub tag override (derived from git_ref if omitted)'
required: false
type: string
env:
DOCKERHUB_REPO: electricax/agents-server
jobs:
derive_build_vars:
name: Derive build variables from the source code
runs-on: blacksmith-2vcpu-ubuntu-2404
outputs:
git_ref: ${{ steps.git_ref.outputs.git_ref }}
image_tags: ${{ steps.vars.outputs.image_tags }}
steps:
- name: Determine the ref to check out
id: git_ref
env:
INPUT_GIT_REF: ${{ inputs.git_ref }}
INPUT_DOCKER_TAG: ${{ inputs.docker_tag }}
COMMIT_SHA: ${{ github.sha }}
run: |
if [ -n "$INPUT_DOCKER_TAG" ]; then
ref="$INPUT_GIT_REF"
build_mode=custom
elif [ -n "$INPUT_GIT_REF" ]; then
ref="refs/tags/$INPUT_GIT_REF"
build_mode=release
else
ref="$COMMIT_SHA"
build_mode=canary
fi
echo "git_ref=$ref" >> $GITHUB_OUTPUT
echo "build_mode=$build_mode" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
ref: ${{ steps.git_ref.outputs.git_ref }}
fetch-depth: 0
fetch-tags: true
- name: Determine final image tags
id: vars
env:
BUILD_MODE: ${{ steps.git_ref.outputs.build_mode }}
INPUT_DOCKER_TAG: ${{ inputs.docker_tag }}
run: |
AGENT_SERVER_VERSION=$(
git describe --abbrev=7 --tags --always --first-parent --match '@electric-ax/agents-server@*' | sed -En 's|^@electric-ax/agents-server@||p'
)
if [ -n "$INPUT_DOCKER_TAG" ]; then
IMAGE_TAGS="${DOCKERHUB_REPO}:${INPUT_DOCKER_TAG}"
elif [ "$BUILD_MODE" = "release" ]; then
IMAGE_TAGS=$(
printf '%s\n%s\n' \
"${DOCKERHUB_REPO}:latest" \
"${DOCKERHUB_REPO}:${AGENT_SERVER_VERSION}"
)
else
IMAGE_TAGS="${DOCKERHUB_REPO}:canary"
fi
{
echo "image_tags<<EOF"
echo "$IMAGE_TAGS"
echo "EOF"
} >> "$GITHUB_OUTPUT"
build_and_publish_image:
needs: [derive_build_vars]
uses: ./.github/workflows/docker_multiarch_image.yml
secrets: inherit
with:
git_ref: ${{ needs.derive_build_vars.outputs.git_ref }}
image_repo: electricax/agents-server
context: .
file: packages/agents-server/Dockerfile
tags: ${{ needs.derive_build_vars.outputs.image_tags }}