wm-AllKids-tibi2023/.gitea/workflows/deploy.yaml
robin 0d40901e57
Some checks failed
deploy to production / deploy (push) Failing after 1m23s
lighthouse
2023-12-06 07:56:57 +00:00

183 lines
6.9 KiB
YAML

name: deploy to production
on: "push"
jobs:
deploy:
name: deploy
runs-on: ubuntu-latest
container:
image: gitbase.de/actions/ubuntu:latest
volumes:
- /data:/data
services:
mongo:
image: mongo:4.2
ports:
- 27017:27017
#maildev:
# image: maildev/maildev
# ports:
# - 80:80
# - 25:25
#
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"
#live-server:
# image: gitbase.de/robin/live-server
# ports:
# - 80:80
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup node 18
uses: actions/setup-node@v3
# with:
# node-version: 18
# cache: yarn
- name: install dependencies
env:
FORCE_COLOR: "true"
run: |
npm install -g yarn
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
# rm api/templates/spa.html
# cp frontend/spa.html api/templates/spa.html
echo ______ frontend/spa.html ______
cat frontend/spa.html
- name: stop Live Server
run: |
docker stop live-server-container
docker rm live-server-container
- name: Start Live Server
run: |
ls -la
echo ${{ github.workspace }}
pwd
docker run -d --name live-server-container -p 8081:8081 gitbase.de/robin/live-server
- name: Wait for Live Server
run: |
attempts=0
max_attempts=10
while ! curl --output /dev/null --silent --head --fail http://127.0.0.1:8081; do
if [ $attempts -eq $max_attempts ]; then
echo "Live server not ready after $max_attempts attempts"
echo "Printing container logs:"
docker logs live-server-container
echo "Printing contents of the working directory in the container:"
docker exec live-server-container ls -la /usr/src/app
exit 1
fi
attempts=$((attempts+1))
echo "Waiting for live-server to be ready... attempt $attempts"
sleep 5
done
- name: Test HTTP Request
run: curl http://127.0.0.1:8081
- name: stop Live Server
run: |
docker stop live-server-container
docker rm live-server-container
#- name: staging api testtest
# if: github.ref == 'refs/heads/dev'
# run: |
# targetDir=/data/${GITHUB_REPOSITORY}/${GITHUB_REF_NAME}
# mkdir -p targetDir
# rsync -av api $targetDir/
# mkdir -p $targetDir/frontend/dist
# rsync -av frontend/dist/ $targetDir/frontend/dist/
#- name: staging frontend
# if: github.ref == 'refs/heads/dev'
# run: |
# docker compose -p ${GITHUB_REF_NAME}-${GITHUB_REPOSITORY_NAME}-${GITHUB_REPOSITORY_OWNER} up -d --build --remove-orphans
- name: Install Chrome
run: |
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install -y google-chrome-stable
# Lighthouse Analysis Step
- name: Lighthouse Analysis
run: |
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"
# Notify-Lighthouse Step
- 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
- name: build
env:
FORCE_COLOR: "true"
run: |
yarn build
#- name: build ssr
# env:
# FORCE_COLOR: "true"
# run: |
# yarn build:server
- name: build legacy
env:
FORCE_COLOR: "true"
run: |
yarn build:legacy
- name: deploy
if: github.ref == 'refs/heads/master'
env:
RSYNC_USER: "allkids_rsync_master"
RSYNC_PASS: ${{ secrets.rsync_master }}
run: |
scripts/deploy.sh ftp1.webmakers.de $RSYNC_USER $RSYNC_PASS