Skip to content

Commit 8f74226

Browse files
Merge branch 'freeCodeCamp:main' into main
2 parents b71c439 + f4ed569 commit 8f74226

File tree

3,095 files changed

+161789
-34781
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,095 files changed

+161789
-34781
lines changed

.github/labeler.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
'scope: docs':
2-
- docs/**/*
3-
41
'scope: curriculum':
52
- curriculum/challenges/**/*
63

74
'platform: learn':
85
- client/**/*
96

107
'platform: api':
11-
- api-server/**/*
128
- api/**/*
139

1410
'scope: tools/scripts':
@@ -18,8 +14,6 @@
1814
- e2e/**/*
1915

2016
'scope: i18n':
21-
- any: ['curriculum/challenges/**/*', '!curriculum/challenges/english/**/*']
22-
- docs/i18n/**/*
2317
- client/i18n/**/*
2418
- config/crowdin/**/*
2519
- shared/config/i18n/**/*

.github/workflows/curriculum-i18n-submodule.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
node-version: [20]
20+
node-version: [22]
2121
# Exclude the languages that we currently run in the full CI suite.
2222
locale:
2323
- 'chinese'
@@ -28,19 +28,21 @@ jobs:
2828
- 'swahili'
2929

3030
steps:
31-
- name: Checkout Source Files
32-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
31+
- name: Checkout
32+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
3333
with:
3434
submodules: 'recursive'
3535

36-
- name: Setup pnpm
37-
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d #v3.0.0
38-
3936
- name: Use Node.js ${{ matrix.node-version }}
40-
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
37+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
4138
with:
4239
node-version: ${{ matrix.node-version }}
43-
cache: pnpm
40+
41+
- name: Install pnpm
42+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
43+
id: pnpm-install
44+
with:
45+
run_install: false
4446

4547
- name: Set Environment variables
4648
run: |
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
name: CD - Deploy - Clients
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
setup-jobs:
8+
name: Setup Jobs
9+
runs-on: ubuntu-22.04
10+
outputs:
11+
site_tld: ${{ steps.setup.outputs.site_tld }} # org, dev
12+
tgt_env_short: ${{ steps.setup.outputs.tgt_env_short }} # prd, stg
13+
tgt_env_long: ${{ steps.setup.outputs.tgt_env_long }} # production, staging
14+
tgt_env_branch: ${{ steps.setup.outputs.tgt_env_branch }} # prod-current, prod-staging
15+
steps:
16+
- name: Setup
17+
id: setup
18+
run: |
19+
BRANCH="${{ github.ref_name }}"
20+
echo "Current branch: $BRANCH"
21+
case "$BRANCH" in
22+
"prod-current")
23+
echo "site_tld=org" >> $GITHUB_OUTPUT
24+
echo "tgt_env_short=prd" >> $GITHUB_OUTPUT
25+
echo "tgt_env_long=production" >> $GITHUB_OUTPUT
26+
echo "tgt_env_branch=prod-current" >> $GITHUB_OUTPUT
27+
;;
28+
*)
29+
echo "site_tld=dev" >> $GITHUB_OUTPUT
30+
echo "tgt_env_short=stg" >> $GITHUB_OUTPUT
31+
echo "tgt_env_long=staging" >> $GITHUB_OUTPUT
32+
echo "tgt_env_branch=prod-staging" >> $GITHUB_OUTPUT
33+
;;
34+
esac
35+
36+
client:
37+
name: Clients - [${{ needs.setup-jobs.outputs.tgt_env_short }}] [${{ matrix.lang-name-short }}]
38+
needs: [setup-jobs]
39+
runs-on: ubuntu-22.04
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
node-version: [22]
44+
lang-name-full:
45+
- english
46+
- chinese
47+
- espanol
48+
- chinese-traditional
49+
- italian
50+
- portuguese
51+
- ukrainian
52+
- japanese
53+
- german
54+
- swahili
55+
include:
56+
- lang-name-full: english
57+
lang-name-short: eng
58+
- lang-name-full: chinese
59+
lang-name-short: chn
60+
- lang-name-full: espanol
61+
lang-name-short: esp
62+
- lang-name-full: chinese-traditional
63+
lang-name-short: cnt
64+
- lang-name-full: italian
65+
lang-name-short: ita
66+
- lang-name-full: portuguese
67+
lang-name-short: por
68+
- lang-name-full: ukrainian
69+
lang-name-short: ukr
70+
- lang-name-full: japanese
71+
lang-name-short: jpn
72+
- lang-name-full: german
73+
lang-name-short: ger
74+
- lang-name-full: swahili
75+
lang-name-short: swa
76+
permissions:
77+
deployments: write
78+
contents: read
79+
environment:
80+
name: ${{ needs.setup-jobs.outputs.tgt_env_short }}-clients
81+
env:
82+
TS_USERNAME: ${{ secrets.TS_USERNAME }}
83+
TS_MACHINE_NAME_PREFIX: ${{ secrets.TS_MACHINE_NAME_PREFIX }}
84+
85+
steps:
86+
- name: Checkout
87+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
88+
with:
89+
submodules: 'recursive'
90+
91+
- name: Use Node.js ${{ matrix.node-version }}
92+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
93+
with:
94+
node-version: ${{ matrix.node-version }}
95+
96+
- name: Install pnpm
97+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
98+
id: pnpm-install
99+
with:
100+
run_install: false
101+
102+
- name: Language specific ENV - [${{ matrix.lang-name-full }}]
103+
run: |
104+
if [ "${{ matrix.lang-name-full }}" = "english" ]; then
105+
echo "HOME_LOCATION=https://www.freecodecamp.${{ needs.setup-jobs.outputs.site_tld }}" >> $GITHUB_ENV
106+
echo "NEWS_LOCATION=https://www.freecodecamp.${{ needs.setup-jobs.outputs.site_tld }}/news" >> $GITHUB_ENV
107+
else
108+
echo "HOME_LOCATION=https://www.freecodecamp.${{ needs.setup-jobs.outputs.site_tld }}/${{ matrix.lang-name-full }}" >> $GITHUB_ENV
109+
echo "NEWS_LOCATION=https://www.freecodecamp.${{ needs.setup-jobs.outputs.site_tld }}/${{ matrix.lang-name-full }}/news" >> $GITHUB_ENV
110+
fi
111+
echo "CLIENT_LOCALE=${{ matrix.lang-name-full }}" >> $GITHUB_ENV
112+
echo "CURRICULUM_LOCALE=${{ matrix.lang-name-full }}" >> $GITHUB_ENV
113+
114+
- name: Install and Build
115+
env:
116+
API_LOCATION: 'https://api.freecodecamp.${{ needs.setup-jobs.outputs.site_tld }}'
117+
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
118+
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
119+
GROWTHBOOK_URI: ${{ secrets.GROWTHBOOK_URI }}
120+
FORUM_LOCATION: 'https://forum.freecodecamp.org'
121+
PATREON_CLIENT_ID: ${{ secrets.PATREON_CLIENT_ID }}
122+
PAYPAL_CLIENT_ID: ${{ secrets.PAYPAL_CLIENT_ID }}
123+
STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_PUBLIC_KEY }}
124+
SHOW_UPCOMING_CHANGES: ${{ vars.SHOW_UPCOMING_CHANGES || 'false' }}
125+
FREECODECAMP_NODE_ENV: production
126+
# The below is used in ecosystem.config.js file for the API -- to be removed later
127+
DEPLOYMENT_ENV: ${{ needs.setup-jobs.outputs.tgt_env_long }}
128+
# The above is used in ecosystem.config.js file for the API -- to be removed later
129+
run: |
130+
pnpm install
131+
pnpm run build
132+
133+
- name: Tar Files
134+
run: tar -czf client-${{ matrix.lang-name-short }}.tar client/public
135+
136+
- name: Setup and connect to Tailscale network
137+
uses: tailscale/github-action@v3
138+
with:
139+
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
140+
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
141+
hostname: gha-${{needs.setup-jobs.outputs.tgt_env_short}}-clients-ci-${{ github.run_id }}
142+
tags: tag:ci
143+
version: latest
144+
145+
- name: Configure SSH & Check Connection
146+
run: |
147+
mkdir -p ~/.ssh
148+
echo "Host *
149+
UserKnownHostsFile=/dev/null
150+
StrictHostKeyChecking no" > ~/.ssh/config
151+
chmod 644 ~/.ssh/config
152+
sleep 10
153+
for i in {0..1}; do
154+
TS_MACHINE_NAME=${TS_MACHINE_NAME_PREFIX}-${{ matrix.lang-name-short }}-${i}
155+
tailscale status | grep -q "$TS_MACHINE_NAME" || { echo "Machine not found"; exit 1; }
156+
sleep 1
157+
MACHINE_IP=$(tailscale ip -4 $TS_MACHINE_NAME)
158+
ssh $TS_USERNAME@$MACHINE_IP "uptime"
159+
done
160+
161+
- name: Upload and Deploy
162+
run: |
163+
for i in {0..1}; do
164+
TS_MACHINE_NAME=${TS_MACHINE_NAME_PREFIX}-${{ matrix.lang-name-short }}-${i}
165+
CURRENT_DATE=$(date +%Y%m%d)
166+
CLIENT_SRC=client-${{ matrix.lang-name-short }}.tar
167+
CLIENT_DST=/tmp/client-${{ matrix.lang-name-short }}-${CURRENT_DATE}-${{ github.run_id }}.tar
168+
CLIENT_BINARIES=${{needs.setup-jobs.outputs.tgt_env_short}}-release-$CURRENT_DATE-${{ github.run_id }}
169+
170+
echo -e "\nLOG:Uploading client archive to $TS_MACHINE_NAME..."
171+
MACHINE_IP=$(tailscale ip -4 $TS_MACHINE_NAME)
172+
scp $CLIENT_SRC $TS_USERNAME@$MACHINE_IP:$CLIENT_DST
173+
174+
REMOTE_SCRIPT="
175+
set -e
176+
echo -e '\nLOG: Deploying client - $CLIENT_BINARIES to $TS_MACHINE_NAME...'
177+
178+
echo -e '\nLOG:Extracting client archive...'
179+
mkdir -p /home/$TS_USERNAME/client/releases/$CLIENT_BINARIES
180+
tar -xzf $CLIENT_DST -C /home/$TS_USERNAME/client/releases/$CLIENT_BINARIES --strip-components=2
181+
182+
echo -e '\nLOG:Cleaning up client archive...'
183+
rm $CLIENT_DST
184+
185+
echo -e '\nLOG:Checking client archive size...'
186+
du -sh /home/$TS_USERNAME/client/releases/$CLIENT_BINARIES
187+
188+
echo -e '\nLOG:Environment setup...'
189+
cd /home/$TS_USERNAME/client
190+
export NVM_DIR=\$HOME/.nvm && [ -s "\$NVM_DIR/nvm.sh" ] && source "\$NVM_DIR/nvm.sh"
191+
echo -e '\nLOG:Checking available Node.js versions...'
192+
nvm ls | grep 'default'
193+
echo -e '\nLOG:Checking Node.js version...'
194+
node --version
195+
196+
echo -e '\nLOG:Installing serve...'
197+
npm install -g serve@13
198+
199+
echo -e '\nLOG:Primary client setup...'
200+
rm -f client-start-primary.sh
201+
echo \"serve -c ../../serve.json releases/$CLIENT_BINARIES -p 50505\" >> client-start-primary.sh
202+
chmod +x client-start-primary.sh
203+
pm2 delete client-primary || true
204+
pm2 start ./client-start-primary.sh --name client-primary
205+
echo -e '\nLOG:Primary client setup completed.'
206+
207+
pm2 ls
208+
209+
echo -e '\nLOG:Secondary client setup...'
210+
rm -f client-start-secondary.sh
211+
echo \"serve -c ../../serve.json releases/$CLIENT_BINARIES -p 52525\" >> client-start-secondary.sh
212+
chmod +x client-start-secondary.sh
213+
pm2 delete client-secondary || true
214+
pm2 start ./client-start-secondary.sh --name client-secondary
215+
echo -e '\nLOG:Secondary client setup completed.'
216+
217+
pm2 ls
218+
pm2 save
219+
220+
echo -e '\nLOG:Finished deployment.'
221+
"
222+
ssh $TS_USERNAME@$MACHINE_IP "$REMOTE_SCRIPT"
223+
done

0 commit comments

Comments
 (0)