From 3bf68bfde01c054a0838a18a2147478a36e42923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Murat=20O=CC=88zkorkmaz?= Date: Fri, 17 Oct 2025 16:18:02 +0200 Subject: [PATCH] CI Test --- .gitea/workflows/deploy.yml | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..0daa7d6 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,76 @@ +name: Build, Push & Deploy Angular App + +on: + push: + branches: + - main + # Optional: führe auch bei Tag-Releases ein Deployment durch + tags: + - '*' + +jobs: + build: + name: 🏗️ Build Docker Image + runs-on: docker + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Install Docker client + run: | + apk add --no-cache docker-cli bash + + - name: Build Docker Image + run: | + chmod +x ./docker/build.sh + cd docker + ./build.sh "${{ env.IMAGE_NAME }}" "${{ env.TAG }}" + + env: + IMAGE_NAME: angular-web-app + TAG: ${{ github.ref_name == 'main' && 'latest' || github.ref_name }} + + push: + name: ⬆️ Push Image to Gitea Registry + runs-on: docker + needs: build + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Push Image + run: | + apk add --no-cache bash docker-cli + cd docker + chmod +x ./push-to-gitea.sh + export GITEA_REGISTRY="${{ env.GITEA_REGISTRY }}" + export GITEA_USER="${{ secrets.CI_REGISTRY_USER }}" + export GITEA_TOKEN="${{ secrets.CI_REGISTRY_PASSWORD }}" + ./push-to-gitea.sh "${{ env.IMAGE_NAME }}" "${{ env.TAG }}" + env: + IMAGE_NAME: angular-web-app + TAG: ${{ github.ref_name == 'main' && 'latest' || github.ref_name }} + GITEA_REGISTRY: gitea.moz-tech.de + + deploy: + name: 🚀 Deploy to Remote Server + runs-on: docker + needs: push + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') + steps: + - name: Prepare environment + run: apk add --no-cache openssh-client docker-cli + + - name: Deploy via SSH + run: | + echo "${{ secrets.DEPLOY_KEY }}" > /tmp/deploy_key.pem + chmod 600 /tmp/deploy_key.pem + + ssh -i /tmp/deploy_key.pem -o StrictHostKeyChecking=no \ + ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} <<'EOF' + docker login gitea.moz-tech.de -u "${{ secrets.CI_REGISTRY_USER }}" -p "${{ secrets.CI_REGISTRY_PASSWORD }}" + docker pull gitea.moz-tech.de/${{ secrets.CI_REGISTRY_USER }}/angular-web-app:latest + docker stop angular-web-app || true + docker rm angular-web-app || true + docker run -d --name angular-web-app -p 80:80 gitea.moz-tech.de/${{ secrets.CI_REGISTRY_USER }}/angular-web-app:latest + EOF