-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (128 loc) · 4.98 KB
/
Copy pathbuild-ai-dev.yml
File metadata and controls
145 lines (128 loc) · 4.98 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Build and publish ai-dev container image
# Triggered on changes to dot_files/ai-dev/, after nvim-dev builds, or manual dispatch
# Image published to: ghcr.io/binarypie-dev/ai-dev:latest
name: Build ai-dev Image
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
paths:
- 'dot_files/ai-dev/**'
- '.github/workflows/build-ai-dev.yml'
pull_request:
paths:
- 'dot_files/ai-dev/**'
- '.github/workflows/build-ai-dev.yml'
workflow_run:
workflows: ["Build nvim-dev Image"]
types:
- completed
workflow_dispatch:
env:
IMAGE_NAME: ai-dev
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
jobs:
build:
name: build ${{ matrix.display }}
runs-on: ${{ matrix.runner }}
# Skip if triggered by failed nvim-dev workflow
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest-m
suffix: amd64
display: x86
- platform: linux/arm64
runner: ubuntu-latest-m-arm
suffix: arm64
display: arm
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Docker (ARM)
if: matrix.suffix == 'arm64'
run: |
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
sudo systemctl start docker
sudo chmod 666 /var/run/docker.sock
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest-${{ matrix.suffix }},enable=${{ github.ref == 'refs/heads/main' }}
type=sha,prefix=,suffix=-${{ matrix.suffix }}
type=ref,event=pr,suffix=-${{ matrix.suffix }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: dot_files/ai-dev
file: dot_files/ai-dev/Containerfile
platforms: ${{ matrix.platform }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.suffix }}
cache-to: type=gha,mode=max,scope=${{ matrix.suffix }}
provenance: false
manifest:
needs: build
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
packages: write
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push manifest
env:
SHORT_SHA: ${{ github.sha }}
run: |
SHORT_SHA=${SHORT_SHA::7}
docker manifest create ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64 \
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64
docker manifest push ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
# Also create SHA manifest
docker manifest create ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${SHORT_SHA} \
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${SHORT_SHA}-amd64 \
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${SHORT_SHA}-arm64
docker manifest push ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${SHORT_SHA}
- name: Generate build summary
run: |
echo "## ai-dev Image Built" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Image:** \`${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:latest\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Usage" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "# Run Claude Code" >> $GITHUB_STEP_SUMMARY
echo "podman run --rm -it --user root --security-opt label=disable \\" >> $GITHUB_STEP_SUMMARY
echo " -e HOST_UID=\$(id -u) -e HOST_GID=\$(id -g) -e HOME=\$HOME \\" >> $GITHUB_STEP_SUMMARY
echo " -v \"\$(pwd):\$(pwd):rw\" -w \"\$(pwd)\" \\" >> $GITHUB_STEP_SUMMARY
echo " ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:latest claude" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY