wm-AllKids-tibi2023/.gitea/workflows/deploy.yaml

110 lines
4.3 KiB
YAML
Raw Normal View History

2023-09-17 13:24:39 +02:00
name: deploy to production
on: "push"
jobs:
deploy:
name: deploy
runs-on: ubuntu-latest
container:
image: gitbase.de/actions/ubuntu:latest
volumes:
- /data:/data
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup node 18
uses: actions/setup-node@v3
2023-09-20 10:28:14 +02:00
# with:
# node-version: 18
# cache: yarn
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
- 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
2023-09-20 10:40:45 +02:00
#- name: staging api testtest
2023-09-17 13:24:39 +02:00
# 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/
2023-09-20 10:57:47 +02:00
#- name: staging frontend
2023-09-17 13:24:39 +02:00
# if: github.ref == 'refs/heads/dev'
# run: |
# docker compose -p ${GITHUB_REF_NAME}-${GITHUB_REPOSITORY_NAME}-${GITHUB_REPOSITORY_OWNER} up -d --build --remove-orphans
2023-12-01 11:24:51 +01:00
# Lighthouse Analysis Step
- name: Lighthouse Analysis
run: |
2023-12-01 11:33:26 +01:00
mkdir -p ${{ github.workspace }}/lighthouse-reports
docker run --rm -v ${{ github.workspace }}/lighthouse-reports:/lighthouse-reports femtopixel/google-lighthouse https://www.webmakers.de/ --output json --output-path /lighthouse-reports/lighthouse-report.json --chrome-flags="--headless --no-sandbox --disable-dev-shm-usage"
2023-12-01 11:24:51 +01:00
# Notify-Lighthouse Step
- name: Notify Lighthouse
run: |
docker run --rm \
2023-12-01 11:31:34 +01:00
-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 }}/lighthouse-reports:/lighthouse-reports \
drillster/drone-email /lighthouse-reports/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