Skip to content

Commit 5ed660e

Browse files
committed
allow custom experiments
1 parent 1fbf9ff commit 5ed660e

File tree

2 files changed

+48
-7
lines changed

2 files changed

+48
-7
lines changed

.github/workflows/pr-deploy.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@ on:
77
inputs:
88
pr_number:
99
description: "PR number"
10+
type: number
1011
required: true
1112
skip_build:
1213
description: "Skip build job"
1314
required: false
15+
type: boolean
1416
default: false
17+
experiments:
18+
description: "Experiments to enable"
19+
required: false
20+
type: string
21+
default: "*"
1522

1623
env:
1724
REPO: ghcr.io/coder/coder-preview
@@ -229,6 +236,20 @@ jobs:
229236
kubectl create secret generic coder-db-url -n pr${{ env.PR_NUMBER }} \
230237
--from-literal=url="postgres://coder:coder@coder-db-postgresql.pr${{ env.PR_NUMBER }}.svc.cluster.local:5432/coder?sslmode=disable"
231238
239+
- name: Get experiments
240+
id: get_experiments
241+
run: |
242+
set -euxo pipefail
243+
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
244+
experiments=${{ github.event.inputs.experiments }}
245+
else
246+
experiments=$(echo "${{ github.event.comment.body }}" | grep -oP '(?<=--experiments ).*')
247+
if [ -z "$experiments" ]; then
248+
experiments="*"
249+
fi
250+
fi
251+
echo "experiments=$experiments" >> $GITHUB_OUTPUT
252+
232253
- name: Create values.yaml
233254
run: |
234255
cat <<EOF > pr-deploy-values.yaml
@@ -245,7 +266,7 @@ jobs:
245266
- name: "CODER_WILDCARD_ACCESS_URL"
246267
value: "*.${{ env.PR_DEPLOYMENT_ACCESS_URL }}"
247268
- name: "CODER_EXPERIMENTS"
248-
value: "*"
269+
value: "${{ steps.get_experiments.outputs.experiments }}"
249270
- name: CODER_PG_CONNECTION_URL
250271
valueFrom:
251272
secretKeyRef:

scripts/deploy-pr.sh

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,43 @@ set -euo pipefail
99
skipBuild=false
1010
dryRun=false
1111
confirm=true
12+
experiments=""
1213

1314
# parse arguments
14-
for arg in "$@"; do
15-
case $arg in
15+
while (("$#")); do
16+
case "$1" in
1617
-s | --skip-build)
1718
skipBuild=true
18-
shift # Remove --skip-build from processing
19+
shift
1920
;;
2021
-n | --dry-run)
2122
dryRun=true
22-
shift # Remove --dry-run from processing
23+
shift
24+
;;
25+
-e | --experiments)
26+
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
27+
experiments="$2"
28+
shift
29+
else
30+
echo "Error: Argument for $1 is missing" >&2
31+
exit 1
32+
fi
33+
shift
2334
;;
2435
-y | --yes)
2536
confirm=false
26-
shift # Remove --yes from processing
37+
shift
38+
;;
39+
--)
40+
shift
41+
break
42+
;;
43+
-* | --*)
44+
echo "Error: Unsupported flag $1" >&2
45+
exit 1
2746
;;
2847
*)
29-
shift # Remove generic argument from processing
48+
shift
3049
;;
3150
esac
3251
done
@@ -61,6 +80,7 @@ if $dryRun; then
6180
echo "branchName: ${branchName}"
6281
echo "prNumber: ${prNumber}"
6382
echo "skipBuild: ${skipBuild}"
83+
echo "experiments: ${experiments}"
6484
exit 0
6585
fi
6686

0 commit comments

Comments
 (0)