-
Notifications
You must be signed in to change notification settings - Fork 8
170 lines (144 loc) · 6 KB
/
Copy pathci.yml
File metadata and controls
170 lines (144 loc) · 6 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: write
pull-requests: write
packages: write
concurrency:
group: dagger-ci-${{ github.ref }}
cancel-in-progress: true
jobs:
dagger-ci:
runs-on: [monorepo-runner-set]
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- uses: 1password/load-secrets-action/configure@v2
with:
connect-host: http://onepassword-connect.1password.svc.cluster.local:8080
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- uses: 1password/load-secrets-action@v2
with:
export-env: true
env:
NPM_TOKEN: op://bic45kuflnwsnxnd67dzcnxjze/5p65mbzr237yyzt2sfnfao3a5a/NPM_TOKEN
GH_TOKEN: op://bic45kuflnwsnxnd67dzcnxjze/5p65mbzr237yyzt2sfnfao3a5a/GH_TOKEN
OPENAI_API_KEY: op://bic45kuflnwsnxnd67dzcnxjze/5p65mbzr237yyzt2sfnfao3a5a/OPENAI_API_KEY
S3_ACCESS_KEY_ID: op://bic45kuflnwsnxnd67dzcnxjze/5p65mbzr237yyzt2sfnfao3a5a/S3_ACCESS_KEY_ID
S3_SECRET_ACCESS_KEY: op://bic45kuflnwsnxnd67dzcnxjze/5p65mbzr237yyzt2sfnfao3a5a/S3_SECRET_ACCESS_KEY
- name: Extract kubectl version
id: kubectl-version
run: |
KUBECTL_VERSION=v1.34.1
echo "version=$KUBECTL_VERSION" >> "$GITHUB_OUTPUT"
- name: Cache kubectl
uses: actions/cache@v4
id: kubectl-cache
with:
path: ~/.local/bin/kubectl
key: kubectl-${{ steps.kubectl-version.outputs.version }}-linux-amd64
- name: Install kubectl
if: steps.kubectl-cache.outputs.cache-hit != 'true'
run: |
mkdir -p ~/.local/bin
curl -LO "https://dl.k8s.io/release/${{ steps.kubectl-version.outputs.version }}/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl ~/.local/bin/
- name: Add kubectl to PATH
run: echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Extract Dagger version
id: dagger-version
run: |
DAGGER_VERSION=$(jq -r '.engineVersion' dagger.json | sed 's/^v//')
echo "Dagger version from dagger.json: $DAGGER_VERSION"
echo "version=$DAGGER_VERSION" >> "$GITHUB_OUTPUT"
- name: Cache Dagger CLI
uses: actions/cache@v4
id: dagger-cache
with:
path: ~/.local/bin/dagger
key: dagger-${{ steps.dagger-version.outputs.version }}-linux-amd64
- name: Install Dagger CLI
if: steps.dagger-cache.outputs.cache-hit != 'true'
run: |
set -euo pipefail
DAGGER_VERSION="${{ steps.dagger-version.outputs.version }}"
BIN_DIR="$HOME/.local/bin"
# Try primary source first
if ! curl -fsSL https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION="$DAGGER_VERSION" BIN_DIR="$BIN_DIR" sh; then
echo "WARNING: Primary source (dl.dagger.io) failed, trying GitHub releases..."
# Fallback to GitHub releases
mkdir -p "$BIN_DIR"
DAGGER_URL="https://github.com/dagger/dagger/releases/download/v${DAGGER_VERSION}/dagger_v${DAGGER_VERSION}_linux_amd64.tar.gz"
echo "Downloading from: $DAGGER_URL"
curl -fsSL "$DAGGER_URL" | tar xz -C /tmp
mv /tmp/dagger "$BIN_DIR/dagger"
chmod +x "$BIN_DIR/dagger"
fi
# Verify installation
if [ ! -f "$BIN_DIR/dagger" ]; then
echo "ERROR: Dagger CLI installation failed"
exit 1
fi
"$BIN_DIR/dagger" version
- name: Get Dagger Engine Pod Name
run: |
DAGGER_ENGINE_POD_NAME="$(kubectl get pod --selector=name=dagger-dagger-helm-engine --namespace=dagger --output=jsonpath='{.items[0].metadata.name}')"
echo "_EXPERIMENTAL_DAGGER_RUNNER_HOST=kube-pod://$DAGGER_ENGINE_POD_NAME?namespace=dagger" >> "$GITHUB_ENV"
- name: Check Dagger version compatibility
run: |
CLI_VERSION=$(dagger version | head -1 | awk '{print $2}')
ENGINE_IMAGE=$(kubectl get pod --selector=name=dagger-dagger-helm-engine --namespace=dagger -o jsonpath='{.items[0].spec.containers[0].image}' 2>/dev/null || echo "unknown")
echo "CLI version: $CLI_VERSION"
echo "Remote engine image: $ENGINE_IMAGE"
echo "Expected (dagger.json): v${{ steps.dagger-version.outputs.version }}"
- name: Install Dagger module dependencies
working-directory: .dagger
run: bun install --frozen-lockfile
- name: Run Dagger CI pipeline
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ARGS=(
--source=.
--branch="${{ github.ref_name }}"
--github-token=env:GH_TOKEN
--npm-token=env:NPM_TOKEN
--s3-access-key-id=env:S3_ACCESS_KEY_ID
--s3-secret-access-key=env:S3_SECRET_ACCESS_KEY
)
if [[ "${{ github.ref_name }}" == "main" ]]; then
ARGS+=(
--version="1.0.${{ github.run_number }}"
--git-sha="${{ github.sha }}"
--registry-username="${{ github.actor }}"
--registry-password=env:GITHUB_TOKEN
--commit-back-token=env:GITHUB_TOKEN
)
fi
MAX_RETRIES=5
RETRY=0
until dagger -v call ci "${ARGS[@]}"; do
RETRY=$((RETRY + 1))
if [ "$RETRY" -ge "$MAX_RETRIES" ]; then
echo "Dagger CI failed after $MAX_RETRIES attempts"
exit 1
fi
DELAY=$((10 + RETRY * 10))
echo "Dagger CI failed (attempt $RETRY/$MAX_RETRIES), retrying in ${DELAY}s..."
sleep "$DELAY"
done
- name: Update READMEs via Dagger
if: github.ref_name == 'main'
env:
BASE_BRANCH: ${{ github.ref_name }}
run: |
dagger call update-readmes \
--source=. \
--github-token=env:GH_TOKEN \
--openai-api-key=env:OPENAI_API_KEY \
--base-branch="$BASE_BRANCH"