Repository navigation
83 lines (76 loc) · 3.79 KB
/
Copy pathbootstrap.yml
File metadata and controls
83 lines (76 loc) · 3.79 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
# Copyright (c) 2026 GitOps Manager, S.L.
# SPDX-License-Identifier: Apache-2.0
name: Publish bootstrap pipeline
# Manually triggered — zips this repo and uploads it to the S3 bucket
# setup-pipeline.sh/.ps1 created, which starts a CodeBuild run automatically
# via EventBridge. Uses OIDC to assume an AWS role — no long-lived AWS
# credential is stored in this repo.
#
# Must be run from the "main" branch — the AWS role's trust policy only
# accepts an OIDC token whose ref is refs/heads/main, so dispatching this
# from any other branch will fail at the "configure-aws-credentials" step.
#
# Requires these repository variables (Settings -> Secrets and variables ->
# Actions -> Variables) — not secrets, none of these are sensitive:
# AWS_ROLE_ARN - from the `github_actions_role_arn` Terraform output
# AWS_REGION - the shared services region, e.g. eu-west-1
# S3_BUCKET - from the `bootstrap_bucket` Terraform output
# RUNNER_IMAGE - optional (SaaS, with setup-pipeline RUNNERS=1): the runner image GitOps Manager's runners
# use, by digest. With the subscription's runners/ in this
# repo, the build applies them (scripts/apply_runners.sh).
# RUNNER_CAPTURE_IMAGE - optional (SaaS): the images runners' image
# (runner-images runner-capture: Playwright and the Python
# Kubernetes client), by digest, for State of World captures.
# Unset: those runners use RUNNER_IMAGE, and a capture fails.
# RUNNERS_HOT, RUNNERS_MAX, RUNNERS_LONG_MAX
# - optional (SaaS): how many runners. Ad-hoc: RUNNERS_HOT always
# running (default 3), up to RUNNERS_MAX (10). Long jobs start
# from zero, up to RUNNERS_LONG_MAX (10). Unset keeps the
# default.
on:
workflow_dispatch: {}
permissions:
id-token: write
contents: read
jobs:
upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ vars.AWS_ROLE_ARN }}
aws-region: ${{ vars.AWS_REGION }}
# What the build cannot know from the zip alone: whose repo this is, and
# the runner image (scripts/apply_runners.sh).
- name: Build settings
# Runners only (opt-in): without RUNNER_IMAGE the zip is as before.
if: ${{ vars.RUNNER_IMAGE != '' }}
env:
ORG: ${{ github.repository_owner }}
RUNNER_IMAGE: ${{ vars.RUNNER_IMAGE }}
RUNNERS_HOT: ${{ vars.RUNNERS_HOT }}
RUNNERS_MAX: ${{ vars.RUNNERS_MAX }}
RUNNERS_LONG_MAX: ${{ vars.RUNNERS_LONG_MAX }}
RUNNER_CAPTURE_IMAGE: ${{ vars.RUNNER_CAPTURE_IMAGE }}
run: |
mkdir -p .gom
python3 -c '
import json, os
b = {"github_org": os.environ["ORG"], "runner_image": os.environ["RUNNER_IMAGE"]}
# The images runners (State of World captures): runner-capture.
if os.environ.get("RUNNER_CAPTURE_IMAGE", "").strip():
b["images_image"] = os.environ["RUNNER_CAPTURE_IMAGE"].strip()
# The runner counts the repository sets; unset keeps the module default.
for key, var in (("hot", "RUNNERS_HOT"), ("max", "RUNNERS_MAX"), ("long_max", "RUNNERS_LONG_MAX")):
v = os.environ.get(var, "").strip()
if v:
if not v.isdigit():
raise SystemExit(f"::error::{var} must be a whole number, got {v!r}")
b[key] = int(v)
print(json.dumps(b))' > .gom/build.json
cat .gom/build.json
- name: Zip and upload
run: |
zip -qr /tmp/eksmanager-bootstrap.zip . -x ".git/*"
aws s3 cp /tmp/eksmanager-bootstrap.zip "s3://${{ vars.S3_BUCKET }}/eksmanager-bootstrap.zip"