diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml deleted file mode 100644 index 0e190ff6..00000000 --- a/.github/workflows/build-and-test.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Build and Test - -on: - push: - branches: [ dev ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Build the application - uses: actions/checkout@v3 - - uses: oven-sh/setup-bun@v1 - with: - bun-version: "latest" - - run: bun install - - run: bun run build - - run: bun run test:unit - - run: bun run test:e2e diff --git a/.github/workflows/dev-pipeline.yml b/.github/workflows/dev-pipeline.yml index d0486c82..d251e679 100644 --- a/.github/workflows/dev-pipeline.yml +++ b/.github/workflows/dev-pipeline.yml @@ -1,27 +1,26 @@ name: Dev Pipeline on: + pull_request: + branches: [main] push: - branches: [ dev ] + branches: [main] jobs: - build: + deploy: runs-on: ubuntu-latest - steps: - - name: Deploy dev changes. - uses: appleboy/ssh-action@master - with: - host: "212.227.155.91" - username: "root" - password: "!2Zc727cI1" - port: 22 - script: | - cd ~/apps/online-energieausweis - git reset --hard HEAD - git clean -f -d - git pull origin main - git status - npm install -g bun - bun install - bash build.sh + - uses: actions/checkout@v2 + - uses: appleboy/ssh-action@master + with: + host: ${{ secrets.DEV_HOST }} + username: ${{ secrets.DEV_USERNAME }} + password: ${{ secrets.DEV_PASSWORD }} + port: 22 + script: | + cd ~/online-energieausweis + git reset --hard HEAD + git clean -f -d + git pull origin main + git status + bash build.sh \ No newline at end of file diff --git a/.github/workflows/prod-pipeline.yml b/.github/workflows/prod-pipeline.yml deleted file mode 100644 index 4934f554..00000000 --- a/.github/workflows/prod-pipeline.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Production Deployment - -on: - release: - types: [ created ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Deploy to production. - uses: appleboy/ssh-action@master - with: - host: "212.227.155.91" - username: "root" - password: "!2Zc727cI1" - port: 22 - script: | - cd ~/apps/online-energieausweis - git reset --hard HEAD - git clean -f -d - git pull origin main - git status - npm install -g bun - bun install - bash build.sh diff --git a/build.sh b/build.sh index 2bc9bf9e..991c5a6b 100644 --- a/build.sh +++ b/build.sh @@ -9,38 +9,40 @@ DB_USER="main" DB_PASSWORD="hHMP8cd^N3SnzGRR" DB_PORT=5432 -git_pull_force() { - git reset --hard HEAD - git clean -f -d - git pull origin main -} +# Wir gehen davon aus, dass die Änderungen bereits von GitHub gepullt wurden +# Dieses Skript ist nur dafür gedacht, von GitHub bei einer Automation +# ausgeführt zu werden. Außerdem würde es nicht wirklich Sinn ergeben, wenn das +# Build Skript sich die Änderungen am build Skript holen würde... -# Zuerst müssen wir neue Änderungen von GitHub pullen. -cd ~/apps/$APP_NAME -git_pull_force; +# Als erstes linken wir das package mit bun, damit wir z.B. in online-energieausweis darauf zugreifen können. +bun link +# Dann installieren wir noch einmal alle dependencies, das ist besonders wichtig +# falls wir lokal verlinkte Projekte haben, sonst werden die nicht in unser +# docker image übernommen +bun install -# Dann bauen wir das Docker Image unserer Application -cd ~/apps/$APP_NAME +# Dann stoppen wir unser altes docker image und bauen es neu. docker stop $APP_NAME docker rm $APP_NAME docker build -t $APP_NAME . -# Wir legen ein persistent directory an -PERSISTENT_DIR="${HOME}/persistent/online-energieausweis"; +# Jeder unserer Applikationen hat ein Verzeichnis in dem alle Dateien dauerhaft, +# Versionsunabhängig gespeichert werden. Dieses legen wir hier an, falls es noch +# nicht existiert. +PERSISTENT_DIR="${HOME}/persistent/${APP_NAME}"; mkdir -p $PERSISTENT_DIR; -# Wir legen einen .env file für unsere letsencrypt keys an. -rm -f ~/apps/$APP_NAME/.env; -touch ~/apps/$APP_NAME/.env; -echo "PRIVATE_KEY=$(cat /etc/letsencrypt/live/ibcornelsen.de/privkey.pem | base64 | tr -d '\n')" >> ~/apps/$APP_NAME/.env; -echo "CERTIFICATE=$(cat /etc/letsencrypt/live/ibcornelsen.de/fullchain.pem | base64 | tr -d '\n')" >> ~/apps/$APP_NAME/.env; +# TODO: Wir legen hier die .env Datei an, die die SSL Zertifikate enthält. +# rm -f ~/$APP_NAME/.env; +# touch ~/$APP_NAME/.env; +# echo "PRIVATE_KEY=$(cat /etc/letsencrypt/live/ibcornelsen.de/privkey.pem | base64 | tr -d '\n')" >> ~/$APP_NAME/.env; +# echo "CERTIFICATE=$(cat /etc/letsencrypt/live/ibcornelsen.de/fullchain.pem | base64 | tr -d '\n')" >> ~/$APP_NAME/.env; -# Und starten unsere App wieder. +# Jetzt wo wir alle Vorbereitungen getroffen haben, starten wir das Docker Image und linken es mit der Datenbank. docker run -d --name $APP_NAME --link $DB_CONTAINER_NAME \ -v "${PERSISTENT_DIR}:/persistent" \ - -p "${APP_PORT}:80" \ - $APP_NAME; - -# Crontab Updaten -cd ~/$APP_NAME -crontab .crontab \ No newline at end of file + -v "./node_modules/@ibcornelsen/database:/${APP_NAME}/node_modules/@ibcornelsen/database" \ + -v "./node_modules/@ibcornelsen/api:/${APP_NAME}/node_modules/@ibcornelsen/api" \ + -v "./node_modules/@ibcornelsen/ui:/${APP_NAME}/node_modules/@ibcornelsen/ui" \ + -p "${APP_PORT}:3000" \ + $APP_NAME; \ No newline at end of file