wm-AllKids-tibi2023/.gitea/workflows/deploy.yaml
robin 295f63c685
Some checks failed
deploy to production / lighthouse-evaluation (push) Failing after 20s
deploy to production / deploy (push) Failing after 1m15s
test
2023-12-16 21:28:19 +00:00

209 lines
7.8 KiB
YAML

name: deploy to production
on: "push"
jobs:
lighthouse-evaluation:
runs-on: ubuntu-latest
container:
image: node:20-alpine3.19
env:
API_URL: some-url.com
ports:
- 80
steps:
- uses: actions/checkout@v3
- name: log node & os versions
run: |
node -v
cat /etc/os-release
echo $API_URL
- name: container within a step
uses: docker://node:20-alpine3.19
with:
entrypoint: /usr/local/bin/node
args: -p 2 + 3
- name: log node version
uses: docker://node:20-alpine3.19
with:
entrypoint: /usr/local/bin/node
args: -v
- name: container within a step
uses: docker://node:20-alpine3.19
with:
entrypoint: /usr/local/bin/node
args: -p 2 + 3
- name: log node version
uses: docker://node:20-alpine3.19
with:
entrypoint: /usr/local/bin/node
args: -v
- name: Validate container status
run: |
sleep 10
echo "Listing all running containers..."
docker ps
echo "Checking if specific containers are still running..."
docker ps | grep node:20-alpine3.19
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
options: --health-cmd='mongo --eval "db.adminCommand(\"ping\")"' --health-interval=10s --health-timeout=5s --health-retries=3
maildev:
image: gitbase.de/robin/maildev:latest
ports:
- 80:80
- 25:25
options: --health-cmd='curl -f http://localhost:80' --health-interval=10s --health-timeout=5s --health-retries=3
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"
options: --health-cmd='curl -f http://localhost:8080' --health-interval=10s --health-timeout=5s --health-retries=3
live-server:
image: gitbase.de/robin/live-server:latest
ports:
- 8081:8081
options: --health-cmd='curl -f http://localhost:8081' --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup node 18
uses: actions/setup-node@v3
- 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: 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: Wait for Live Server
run: |
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
- 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 -
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: 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