-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (83 loc) · 2.84 KB
/
Copy pathdocker.yml
File metadata and controls
94 lines (83 loc) · 2.84 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
name: Docker Image
on:
push:
tags: ["v*", "[0-9]+.[0-9]+.[0-9]+"]
workflow_dispatch:
inputs:
image_tag:
description: "Image tag to publish for a manual run, e.g. v0.1.0-canary."
required: true
default: "v0.1.0-canary"
type: string
publish_latest:
description: "Also publish ghcr.io/aipowergrid/validator:latest."
required: true
default: false
type: boolean
env:
IMAGE_NAME: ghcr.io/aipowergrid/validator
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Validate manual image tag
if: ${{ github.event_name == 'workflow_dispatch' }}
shell: bash
run: |
if [[ -z "${{ inputs.image_tag }}" ]]; then
echo "image_tag is required for manual Docker publishes" >&2
exit 1
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=raw,value=${{ inputs.image_tag || 'manual' }},enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' && inputs.publish_latest }}
- name: Build local smoke image
run: docker build -t aipowergrid/validator:publish-smoke .
- name: Smoke-test local image
shell: bash
run: |
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
cat > "$tmp/.env" <<'EOF'
GRID_API_URL=http://127.0.0.1:1
VALIDATOR_API_KEY=grid-key
VALIDATOR_REQUIRE_STAKE=false
PROBE_TIMEOUT_S=1
EOF
set +e
docker run --rm \
--mount type=bind,source="$tmp/.env",target=/app/.env,readonly \
aipowergrid/validator:publish-smoke check --no-probe > "$tmp/check.out" 2>&1
code=$?
set -e
cat "$tmp/check.out"
test "$code" -eq 1
! grep -Ei "Traceback|ModuleNotFoundError|ImportError" "$tmp/check.out"
grep -F "Grid models unavailable" "$tmp/check.out"
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}