-
Notifications
You must be signed in to change notification settings - Fork 39
199 lines (176 loc) Β· 8.2 KB
/
planet.yml
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Planet Builder
on:
push:
branches-ignore:
- l10n_i18n
release:
types: [published]
workflow_dispatch:
inputs:
buildtype:
description: 'Build by "prebuild", "single-language", "planet", or "deploy"'
required: true
default: 'single-language'
env:
DOCKER_ORG: treehouses
DOCKER_REPO_PRE: planet-base
DOCKER_REPO_LANG: planet-lang
DOCKER_REPO_TAG: planet-tags
DOCKER_REPO: planet
jobs:
build-prepare:
name: Preparing
runs-on: ubuntu-latest
outputs:
planet_version: ${{ steps.step1.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setting Env
id: step1
run: |
version=$(jq '.version' package.json | sed -e 's/^"//' -e 's/"$//')
echo "::set-output name=version::$version"
pre-build:
name: Pre-Planet build
needs: [build-prepare]
if: ${{ github.event.inputs.buildtype == 'prebuild' }}
runs-on: ubuntu-latest
env:
PLANET_VERSION: ${{ needs.build-prepare.outputs.planet_version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Docker login
run: docker login -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }}
- name: Pre-Build Planet
run: |
repo="$DOCKER_ORG/$DOCKER_REPO_PRE:$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}"
latestrepo="$DOCKER_ORG/$DOCKER_REPO_PRE:latest"
mkdir -p ./ng-app/dist
docker build -f './docker/planet/pre-builder-Dockerfile' -t $repo .
docker images
docker tag $repo $latestrepo
docker push $repo
docker push $latestrepo
deploy-single-language:
name: Deploy single language build
needs: [build-prepare, pre-build]
if: ${{ (github.event.inputs.buildtype == 'prebuild' || ((github.event.inputs.buildtype == 'single-language' || github.event_name != 'workflow_dispatch') && always())) }}
runs-on: ubuntu-latest
env:
PLANET_VERSION: ${{ needs.build-prepare.outputs.planet_version }}
#strategy:
# matrix:
# lang: [ eng, ara, fra, spa, nep, som ]
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Remove Landing Video
run: |
rm -rf ./src/assets/landing-page/video/landing.mp4
- name: Docker login
run: docker login -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }}
- name: Build single language build
# if: ${{ matrix.lang == 'eng' || github.event.inputs.buildtype == 'single-language' || github.ref_type == 'tag' }}
run: |
repo="$DOCKER_ORG/$DOCKER_REPO_LANG:$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}"
branchrepo="$DOCKER_ORG/$DOCKER_REPO_LANG:$PLANET_VERSION-$GITHUB_REF_NAME"
export NODE_OPTIONS=--max_old_space_size=4096
mkdir -p ./ng-app/dist
docker build -f './docker/planet/builder-Dockerfile' -t $repo .
docker images
docker push $repo
docker tag $repo $branchrepo
docker push $branchrepo
build:
name: Planet build
needs: [build-prepare, deploy-single-language]
if: ${{ (github.event.inputs.buildtype != 'deploy' || (github.event.inputs.buildtype == 'planet' && always())) }}
runs-on: ubuntu-latest
env:
PLANET_VERSION: ${{ needs.build-prepare.outputs.planet_version }}
strategy:
matrix:
arch: [ amd64, arm, arm64 ]
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Docker login
run: docker login -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }}
- name: Build image
run: |
repo="$DOCKER_ORG/$DOCKER_REPO_TAG:${{ matrix.arch }}-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}"
branchrepo="$DOCKER_ORG/$DOCKER_REPO_TAG:${{ matrix.arch }}-$PLANET_VERSION-$GITHUB_REF_NAME"
LANGUAGES=( 'eng' 'ara' 'fra' 'spa' 'nep' 'som')
mkdir -p ./ng-app/dist
mkdir -p ./ng-app/langbuild
docker create --name langbuild "$DOCKER_ORG/$DOCKER_REPO_LANG:$PLANET_VERSION-$GITHUB_REF_NAME"
docker export langbuild > langbuild.tar
tar -xf langbuild.tar -C ./ng-app/langbuild
for LANGUAGE in "${LANGUAGES[@]}"; do
case $LANGUAGE in
eng) : "en" ;;
ara) : "ar" ;;
fra) : "fr" ;;
spa) : "es" ;;
nep) : "ne" ;;
som) : "so" ;;
esac
lang2="$_"
cp -ar ./ng-app/langbuild/ng-app/dist/$lang2 ./ng-app/dist/
mv ./ng-app/dist/$lang2 ./ng-app/dist/$LANGUAGE
done
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker build -f './docker/planet/${{ matrix.arch }}-Dockerfile' -t $repo .
docker images
docker tag $repo $branchrepo
docker push $repo
docker push $branchrepo
multiarch:
name: Manifest build
needs: [ build-prepare, build ]
env:
PLANET_VERSION: ${{ needs.build-prepare.outputs.planet_version }}
if: ${{ always() }}
#if: ${{ (github.ref_type == 'tag' || github.event.inputs.buildtype == 'deploy' || github.ref_name == 'master') && always() }}
runs-on: ubuntu-latest
steps:
- name: Docker login
run: docker login -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }}
- name: Multiarch Deploy
run: |
sudo wget -O /usr/local/bin/manifest_tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64
sudo chmod +x /usr/local/bin/manifest_tool
mkdir -p /tmp/MA_manifests
latesttag="$DOCKER_ORG/$DOCKER_REPO_TAG:$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e -n '.image = strenv(latesttag)' | \
amd64tag="$DOCKER_ORG/$DOCKER_REPO_TAG:amd64-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[0].image = strenv(amd64tag)' - | \
yq e '.manifests[0].platform.architecture = "amd64"' - | \
yq e '.manifests[0].platform.os = "linux"' - | \
armtag="$DOCKER_ORG/$DOCKER_REPO_TAG:arm-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[1].image = strenv(armtag)' - | \
yq e '.manifests[1].platform.architecture = "arm"' - | \
yq e '.manifests[1].platform.os = "linux"' - | \
arm64tag="$DOCKER_ORG/$DOCKER_REPO_TAG:arm64-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[2].image = strenv(arm64tag)' - | \
yq e '.manifests[2].platform.architecture = "arm64"' - | \
yq e '.manifests[2].platform.os = "linux"' - | \
tee /tmp/MA_manifests/MA_planet_latest.yaml
manifest_tool push from-spec /tmp/MA_manifests/MA_planet_latest.yaml
- name: Multiarch Deploy Versioned
if: ${{ github.event_name == 'release' }}
run: |
sudo wget -O /usr/local/bin/manifest_tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64
sudo chmod +x /usr/local/bin/manifest_tool
mkdir -p /tmp/MA_manifests
versiontag="$DOCKER_ORG/$DOCKER_REPO:$PLANET_VERSION" yq e -n '.image = strenv(versiontag)' | \
yq e '.tags |= . + ["latest"] ' - | \
amd64tag="$DOCKER_ORG/$DOCKER_REPO_TAG:amd64-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[0].image = strenv(amd64tag)' - | \
yq e '.manifests[0].platform.architecture = "amd64"' - | \
yq e '.manifests[0].platform.os = "linux"' - | \
armtag="$DOCKER_ORG/$DOCKER_REPO_TAG:arm-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[1].image = strenv(armtag)' - | \
yq e '.manifests[1].platform.architecture = "arm"' - | \
yq e '.manifests[1].platform.os = "linux"' - | \
arm64tag="$DOCKER_ORG/$DOCKER_REPO_TAG:arm64-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[2].image = strenv(arm64tag)' - | \
yq e '.manifests[2].platform.architecture = "arm64"' - | \
yq e '.manifests[2].platform.os = "linux"' - | \
tee /tmp/MA_manifests/MA_planet_versioned.yaml
manifest_tool push from-spec /tmp/MA_manifests/MA_planet_versioned.yaml