Skip to content

Commit ab36762

Browse files
committed
[add]GitHub Actions to build & regster Docker image
1 parent 98e7ec7 commit ab36762

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Publish Agents
2+
3+
# Trigger this workflow when pushing agentbeats/green_agent branch
4+
on:
5+
push:
6+
branches:
7+
- agentbeats/green_agent
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
include:
16+
# FieldWorkArena agent images
17+
- name: fwa-server
18+
dockerfile: Dockerfile
19+
- name: fwa-test-purple-agent
20+
dockerfile: scenarios/fwa/Dockerfile.purple_agent
21+
22+
# These permissions are required for the workflow to:
23+
# - Read repository contents (checkout code)
24+
# - Write to GitHub Container Registry (push Docker images)
25+
permissions:
26+
contents: read
27+
packages: write
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Log in to GitHub Container Registry
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
# GITHUB_TOKEN is automatically provided by GitHub Actions
39+
# No manual secret configuration needed!
40+
# It has permissions based on the 'permissions' block above
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Extract metadata for Docker
44+
id: meta
45+
uses: docker/metadata-action@v5
46+
with:
47+
images: ghcr.io/${{ github.repository }}-${{ matrix.name }}
48+
tags: |
49+
# For tags like v1.0, create tag '1.0'
50+
type=semver,pattern={{version}}
51+
# For tags like v1.0, create tag '1'
52+
type=semver,pattern={{major}}
53+
# For main branch, create tag 'latest'
54+
type=raw,value=latest,enable={{is_default_branch}}
55+
# For PRs, create tag 'pr-123'
56+
type=ref,event=pr
57+
58+
- name: Build and push Docker image (${{ matrix.name }})
59+
id: build
60+
uses: docker/build-push-action@v5
61+
with:
62+
context: .
63+
file: ${{ matrix.dockerfile }}
64+
# Only push if this is a push event (not a PR)
65+
# PRs will build but not push to avoid polluting the registry
66+
push: ${{ github.event_name != 'pull_request' }}
67+
tags: ${{ steps.meta.outputs.tags }}
68+
labels: ${{ steps.meta.outputs.labels }}
69+
# Explicitly build for linux/amd64 (GitHub Actions default)
70+
platforms: linux/amd64
71+
72+
- name: Output image digest
73+
if: github.event_name != 'pull_request'
74+
run: |
75+
echo "## Docker Image Published: ${{ matrix.name }} :rocket:" >> $GITHUB_STEP_SUMMARY
76+
echo "" >> $GITHUB_STEP_SUMMARY
77+
echo "**Tags:** ${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
78+
echo "" >> $GITHUB_STEP_SUMMARY
79+
echo "**Digest:** \`${{ steps.build.outputs.digest }}\`" >> $GITHUB_STEP_SUMMARY
80+
echo "" >> $GITHUB_STEP_SUMMARY
81+
echo "Use this digest in your MANIFEST.json for reproducibility." >> $GITHUB_STEP_SUMMARY

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ docker run -p 9009:9009 --env-file .env fwa_green_agent
115115

116116
**Note:** This only starts the GreenAgent server and does not execute the assessment using test_agent.
117117

118+
**GitHub Actions:** This repository includes a workflow (`.github/workflows/publish.yml`) that automatically builds and publishes Docker images to GitHub Container Registry when pushing to the `agentbeats/green_agent` branch.
119+
118120
## Scenario Configuration
119121

120122
### all_task_ids.toml

0 commit comments

Comments
 (0)