-
Notifications
You must be signed in to change notification settings - Fork 76
150 lines (133 loc) · 5.47 KB
/
publish-chrome.yaml
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
name: Publish Chrome
on:
workflow_dispatch:
inputs:
chrome_version:
description: "Version of Chrome to build"
required: true
type: string
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install the Linode CLI
uses: linode/action-linode-cli@v1
with:
token: ${{ secrets.LINODE_PAT }}
# For some reason, Linodes created via linode-cli do not work with ssh,
# so we have to create the Linode manually and then pull the Linode ID
#
# - name: Create Builder
# id: create_builder
# run: |
# builder_info="$(linode-cli linodes create \
# --authorized_users dclivekit \
# --backups_enabled false \
# --booted true \
# --image linode/ubuntu22.04 \
# --label chrome-builder \
# --private_ip false \
# --region us-west \
# --root_pass '${{ secrets.LINODE_ROOT_PASS }}' \
# --type g6-dedicated-4 \
# --json)"
# builder_id="$(echo $builder_info | jq -r '.[0].id')"
# builder_ip="$(echo $builder_info | jq -r '.[0].ipv4[0]')"
# echo "builder_id: $builder_id"
# echo "builder_ip: $builder_ip"
# echo "builder_id=$builder_id" >> $GITHUB_OUTPUT
# echo "builder_ip=$builder_ip" >> $GITHUB_OUTPUT
# env:
# LINODE_CLI_TOKEN: ${{ secrets.LINODE_PAT }}
- name: Get Builder
id: get_builder
run: |
builder_info="$(linode-cli linodes list --label chrome-builder --json)"
builder_id="$(echo $builder_info | jq -r '.[0].id')"
builder_ip="$(echo $builder_info | jq -r '.[0].ipv4[0]')"
echo "builder_id: $builder_id"
echo "builder_ip: $builder_ip"
echo "builder_id=$builder_id" >> $GITHUB_OUTPUT
echo "builder_ip=$builder_ip" >> $GITHUB_OUTPUT
env:
LINODE_CLI_TOKEN: ${{ secrets.LINODE_PAT }}
- name: Wait for Builder
run: |
status=$(linode-cli linodes view ${{ steps.get_builder.outputs.builder_id }} --json | jq -r '.[0].status')
while [ "$status" == "provisioning" ] || [ "$status" == "booting" ]; do \
echo "Builder status: $status"; \
sleep 5; \
status=$(linode-cli linodes view ${{ steps.get_builder.outputs.builder_id }} --json | jq -r '.[0].status'); \
done
echo "Builder status: $status"
env:
LINODE_CLI_TOKEN: ${{ secrets.LINODE_PAT }}
- name: Write SSH keys
run: |
mkdir ~/.ssh
chmod 700 ~/.ssh
echo "${{ secrets.LINODE_SSH_PUBLIC_KEY }}" > ~/.ssh/linode_ed25519.pub
chmod 600 ~/.ssh/linode_ed25519.pub
echo "${{ secrets.LINODE_SSH_PRIVATE_KEY }}" > ~/.ssh/linode_ed25519
chmod 600 ~/.ssh/linode_ed25519
ssh-keyscan -H ${{ steps.get_builder.outputs.builder_ip }} > ~/.ssh/known_hosts
- name: Setup
run: |
ssh -i ~/.ssh/linode_ed25519 \
-o PasswordAuthentication=no \
-t root@${{ steps.get_builder.outputs.builder_ip }} \
'bash -s' < ./build/chrome/scripts/setup.sh
- name: Amd64
run: |
ssh -i ~/.ssh/linode_ed25519 \
-o PasswordAuthentication=no \
-t chrome@${{ steps.get_builder.outputs.builder_ip }} \
'bash -s ${{ inputs.chrome_version }}' < ./build/chrome/scripts/amd64.sh
- name: Arm64
run: |
ssh -i ~/.ssh/linode_ed25519 \
-o PasswordAuthentication=no \
-o ServerAliveInterval=60 \
-t chrome@${{ steps.get_builder.outputs.builder_ip }} \
'bash -s ${{ inputs.chrome_version }}' < ./build/chrome/scripts/arm64.sh
- name: Drivers
run: |
ssh -i ~/.ssh/linode_ed25519 \
-o PasswordAuthentication=no \
-o ServerAliveInterval=60 \
-t chrome@${{ steps.get_builder.outputs.builder_ip }} \
'bash -s ${{ inputs.chrome_version }}' < ./build/chrome/scripts/driver.sh
- name: Prepare artifacts
run: |
ssh -i ~/.ssh/linode_ed25519 \
-o PasswordAuthentication=no \
-t chrome@${{ steps.get_builder.outputs.builder_ip }} \
'zip -r output.zip ./output'
- name: Download artifacts
run: |
scp -i ~/.ssh/linode_ed25519 \
-o PasswordAuthentication=no \
chrome@${{ steps.get_builder.outputs.builder_ip }}:/home/chrome/output.zip \
${{ github.workspace }}/build/chrome/output.zip
unzip ${{ github.workspace }}/build/chrome/output.zip -d ${{ github.workspace }}/build/chrome
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./build/chrome
file: ./build/chrome/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: livekit/chrome-installer:${{ inputs.chrome_version }}
- name: Delete Linode
run: linode-cli linodes delete ${{ steps.get_builder.outputs.builder_id }}
env:
LINODE_CLI_TOKEN: ${{ secrets.LINODE_PAT }}