2023-09-17 13:24:39 +02:00
|
|
|
name: deploy to production
|
|
|
|
|
|
|
|
on: "push"
|
|
|
|
jobs:
|
2023-12-16 22:12:14 +01:00
|
|
|
lighthouse-evaluation:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
2023-12-17 12:12:39 +01:00
|
|
|
image: ubuntu-latest
|
|
|
|
services:
|
|
|
|
mongo:
|
|
|
|
image: mongo:4.2
|
|
|
|
ports:
|
|
|
|
- 27017:27017
|
2023-12-16 22:12:14 +01:00
|
|
|
|
2023-12-17 12:12:39 +01:00
|
|
|
maildev:
|
|
|
|
image: gitbase.de/robin/maildev:latest
|
|
|
|
ports:
|
|
|
|
- 80:80
|
|
|
|
- 25:25
|
2023-12-16 22:25:58 +01:00
|
|
|
|
2023-12-17 12:12:39 +01:00
|
|
|
tibi-server:
|
|
|
|
image: gitbase.de/cms/tibi-server
|
|
|
|
ports:
|
|
|
|
- 8080:8080
|
|
|
|
env:
|
|
|
|
DB_DIAL: mongodb://mongo
|
|
|
|
API_PORT: 8080
|
|
|
|
MAIL_HOST: maildev:25
|
|
|
|
SECURITY_ALLOWABSOLUTEPATHS: "true"
|
|
|
|
SECURITY_ALLOWUPPERPATHS: "true"
|
|
|
|
SECURITY_ALLOWRELATIVEPATHS: "true"
|
2023-12-16 22:25:58 +01:00
|
|
|
|
2023-12-17 12:12:39 +01:00
|
|
|
live-server:
|
|
|
|
image: gitbase.de/robin/live-server:latest
|
|
|
|
ports:
|
|
|
|
- 8081:8081
|
2023-12-24 10:46:36 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Set up Node.js
|
|
|
|
uses: actions/setup-node@v2
|
|
|
|
with:
|
|
|
|
node-version: "20"
|
|
|
|
|
|
|
|
- name: Load .env file
|
|
|
|
run: |
|
|
|
|
set -a
|
|
|
|
source .env
|
|
|
|
set +a
|
|
|
|
|
|
|
|
- name: Initialize database
|
|
|
|
run: node /.gitea/actions/init-db
|
|
|
|
env:
|
|
|
|
PROJECT_API_NAMESPACE: $TIBI_NAMESPACE
|
|
|
|
MONGODB_URI: mongodb://mongo #service name!
|
|
|
|
TIBI_DB_PREFIX: $TIBI_PREFIX
|
|
|
|
TIBI_API_URL: http://tibi-server:8080/api/v1
|
|
|
|
|
2023-12-16 22:23:08 +01:00
|
|
|
|
2023-09-17 13:24:39 +02:00
|
|
|
deploy:
|
|
|
|
name: deploy
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
|
|
|
image: gitbase.de/actions/ubuntu:latest
|
|
|
|
volumes:
|
|
|
|
- /data:/data
|
2023-12-05 16:20:50 +01:00
|
|
|
|
|
|
|
services:
|
|
|
|
mongo:
|
|
|
|
image: mongo:4.2
|
|
|
|
ports:
|
2023-12-05 16:26:30 +01:00
|
|
|
- 27017:27017
|
2023-12-06 11:28:37 +01:00
|
|
|
|
2023-12-06 11:15:51 +01:00
|
|
|
maildev:
|
2023-12-06 11:28:37 +01:00
|
|
|
image: gitbase.de/robin/maildev:latest
|
2023-12-06 11:15:51 +01:00
|
|
|
ports:
|
|
|
|
- 80:80
|
|
|
|
- 25:25
|
2023-12-06 11:57:17 +01:00
|
|
|
|
2023-12-05 17:02:01 +01:00
|
|
|
tibi-server:
|
|
|
|
image: gitbase.de/cms/tibi-server
|
|
|
|
ports:
|
|
|
|
- 8080:8080
|
|
|
|
env:
|
|
|
|
DB_DIAL: mongodb://mongo
|
|
|
|
API_PORT: 8080
|
|
|
|
MAIL_HOST: maildev:25
|
|
|
|
SECURITY_ALLOWABSOLUTEPATHS: "true"
|
|
|
|
SECURITY_ALLOWUPPERPATHS: "true"
|
|
|
|
SECURITY_ALLOWRELATIVEPATHS: "true"
|
2023-12-05 17:07:34 +01:00
|
|
|
|
2023-12-06 09:58:28 +01:00
|
|
|
live-server:
|
2023-12-06 10:04:11 +01:00
|
|
|
image: gitbase.de/robin/live-server:latest
|
2023-12-06 09:58:28 +01:00
|
|
|
ports:
|
|
|
|
- 8081:8081
|
2023-12-05 21:57:30 +01:00
|
|
|
|
2023-09-17 13:24:39 +02:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: setup node 18
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
|
2023-12-17 12:12:39 +01:00
|
|
|
- name: container within a step
|
|
|
|
uses: docker://node:20-alpine3.19
|
|
|
|
with:
|
|
|
|
entrypoint: echo
|
|
|
|
args: "dastest"
|
2023-12-17 12:15:50 +01:00
|
|
|
- name: check docker networking infos
|
|
|
|
run: |
|
|
|
|
echo "${{ toJson(job) }}"
|
|
|
|
echo "${{ github }}"
|
|
|
|
docker network ls
|
|
|
|
docker network inspect bridge
|
|
|
|
docker network inspect host
|
|
|
|
docker network inspect none
|
|
|
|
docker network inspect container:${{ job.services.tibi-server.id }}
|
|
|
|
docker network inspect container:${{ job.services.live-server.id }}
|
|
|
|
docker network inspect container:${{ job.services.mongo.id }}
|
|
|
|
docker network inspect container:${{ job.services.maildev.id }}
|
2023-12-17 12:12:39 +01:00
|
|
|
|
2023-09-17 13:24:39 +02:00
|
|
|
- name: install dependencies
|
|
|
|
env:
|
|
|
|
FORCE_COLOR: "true"
|
|
|
|
run: |
|
2023-09-20 10:28:14 +02:00
|
|
|
npm install -g yarn
|
2023-09-17 13:24:39 +02:00
|
|
|
yarn install
|
|
|
|
|
|
|
|
- name: modify config
|
|
|
|
run: |
|
|
|
|
sed -i 's#\(sentryEnvironment.*\)".*"#\1"${GITHUB_REF_NAME}"#g' frontend/src/config.ts
|
|
|
|
sed -i 's#//\( sentry\\.init.*\)#\1#g' frontend/src/config.ts
|
|
|
|
export $(cat .env | xargs)
|
|
|
|
echo "PROJECT_RELEASE=${RELEASE_PROJECT_SLUG}.r`git rev-list HEAD --count`-`git describe --all --long | sed 's+/+-+'`" >> .env
|
|
|
|
export $(cat .env | xargs)
|
|
|
|
echo ______ .env ______
|
|
|
|
cat .env
|
|
|
|
echo
|
|
|
|
sed -i 's#\(const release = \).*#\1"'${PROJECT_RELEASE}'"#g' api/hooks/config-client.js
|
|
|
|
|
|
|
|
# bash scripts/preload-meta.sh frontend/spa.html
|
|
|
|
# bash scripts/preload-meta.sh frontend/spa.html > frontend/_spa.html
|
|
|
|
# cp frontend/_spa.html frontend/spa.html
|
|
|
|
|
|
|
|
export stamp=`date +%s`
|
|
|
|
sed -i s/__TIMESTAMP__/$stamp/g frontend/spa.html
|
|
|
|
# sed -i s/__TIMESTAMP__/$stamp/g frontend/serviceworker.js
|
|
|
|
# cat frontend/serviceworker.js
|
2023-09-20 10:28:14 +02:00
|
|
|
# rm api/templates/spa.html
|
|
|
|
# cp frontend/spa.html api/templates/spa.html
|
2023-09-17 13:24:39 +02:00
|
|
|
echo ______ frontend/spa.html ______
|
|
|
|
cat frontend/spa.html
|
2023-12-05 22:30:23 +01:00
|
|
|
|
2023-12-06 14:46:46 +01:00
|
|
|
- name: build
|
|
|
|
env:
|
|
|
|
FORCE_COLOR: "true"
|
|
|
|
run: |
|
|
|
|
yarn build
|
|
|
|
|
2023-12-06 18:57:25 +01:00
|
|
|
- name: build ssr
|
|
|
|
env:
|
|
|
|
FORCE_COLOR: "true"
|
|
|
|
run: |
|
|
|
|
yarn build:server
|
2023-12-06 14:46:46 +01:00
|
|
|
|
|
|
|
- name: build legacy
|
|
|
|
env:
|
|
|
|
FORCE_COLOR: "true"
|
|
|
|
run: |
|
|
|
|
yarn build:legacy
|
|
|
|
|
2023-12-15 21:27:25 +01:00
|
|
|
- name: Wait for Live Server
|
|
|
|
run: |
|
2023-12-15 21:35:14 +01:00
|
|
|
attempts=0
|
|
|
|
max_attempts=2
|
|
|
|
while ! curl --output /dev/null --silent --head --fail http://live-server:8081; do
|
|
|
|
if [ $attempts -eq $max_attempts ]; then
|
|
|
|
echo "Live server not ready after $max_attempts attempts"
|
|
|
|
echo "${{ toJson(job) }}"
|
|
|
|
curl -v http://live-server:8081
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
attempts=$((attempts+1))
|
|
|
|
echo "Waiting for live-server to be ready... attempt $attempts"
|
|
|
|
sleep 5
|
|
|
|
done
|
2023-12-15 21:27:25 +01:00
|
|
|
|
|
|
|
- name: Test HTTP Request
|
|
|
|
run: |
|
|
|
|
echo "Live server not ready after $max_attempts attempts"
|
|
|
|
echo "${{ toJson(job) }}"
|
|
|
|
echo "${{ job.services.live-server.id }}"
|
|
|
|
echo "${{ job.services.tibi-server.id }}"
|
|
|
|
echo "${{ job.services.mongo.id }}"
|
|
|
|
docker logs "${{ job.services.tibi-server.id }}"
|
|
|
|
docker logs "${{ job.services.live-server.id }}"
|
|
|
|
curl -v http://live-server:8081
|
|
|
|
|
|
|
|
- name: Install Chrome
|
|
|
|
run: |
|
|
|
|
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
|
2023-12-15 21:35:14 +01:00
|
|
|
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
|
|
|
|
|
2023-12-15 21:27:25 +01:00
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install -y google-chrome-stable
|
2023-12-05 22:19:04 +01:00
|
|
|
|
2023-12-01 11:24:51 +01:00
|
|
|
# Lighthouse Analysis Step
|
2023-12-15 21:31:46 +01:00
|
|
|
- name: Lighthouse Analysis
|
|
|
|
run: |
|
2023-12-15 21:35:14 +01:00
|
|
|
yarn add lighthouse
|
|
|
|
npx lighthouse http://127.0.0.1:8081 --output json --output-path /tmp/lighthouse-report.json --chrome-flags="--headless --no-sandbox --disable-dev-shm-usage"
|
2023-12-01 11:24:51 +01:00
|
|
|
|
|
|
|
# Notify-Lighthouse Step
|
2023-12-15 21:27:25 +01:00
|
|
|
- name: Notify Lighthouse
|
|
|
|
run: |
|
|
|
|
docker run --rm \
|
|
|
|
-e PLUGIN_FROM=noreply@gitbase.de \
|
|
|
|
-e PLUGIN_HOST=smtp.basehosts.de \
|
|
|
|
-e PLUGIN_RECIPIENT=recipient@example.com \
|
|
|
|
-e PLUGIN_SUBJECT="Lighthouse Report" \
|
|
|
|
-v ${{ github.workspace }}/tmp:/lighthouse-reports \
|
|
|
|
drillster/drone-email /tmp/lighthouse-report.json
|
2023-12-01 11:24:51 +01:00
|
|
|
|
2023-09-17 13:24:39 +02:00
|
|
|
- name: deploy
|
|
|
|
if: github.ref == 'refs/heads/master'
|
|
|
|
env:
|
2023-09-20 10:41:20 +02:00
|
|
|
RSYNC_USER: "allkids_rsync_master"
|
2023-09-17 13:24:39 +02:00
|
|
|
RSYNC_PASS: ${{ secrets.rsync_master }}
|
|
|
|
run: |
|
|
|
|
scripts/deploy.sh ftp1.webmakers.de $RSYNC_USER $RSYNC_PASS
|