Files
enerport-web-app/.gitea/workflows/deploy.yml
Workflow config file is invalid. Please check your config file: yaml: line 81: could not find expected ':'
Murat Özkorkmaz a1a499f877 CI Test
2025-10-17 17:49:57 +02:00

102 lines
3.7 KiB
YAML

name: Build, Push & Deploy Angular App
on:
push:
branches:
- main
tags:
- '*'
jobs:
# build:
# name: 🏗️ Build Docker Image
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v3
#
# - name: Install Docker client
# run: |
# sudo apt-get update
# sudo apt-get install -y docker.io 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: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }}
push:
name: ⬆️ Build and Push Image to Gitea Registry
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Build and Push Image
run: |
sudo apt-get update
sudo apt-get install -y docker.io bash
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: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }}
GITEA_REGISTRY: gitea.moz-tech.de
deploy:
name: 🚀 Deploy to Remote Server
runs-on: ubuntu-latest
needs: push
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
steps:
- name: Prepare environment
run: |
sudo apt-get update
sudo apt-get install -y openssh-client docker.io
- name: Deploy via SSH
run: |
IMAGE_TAG="${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }}"
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:${IMAGE_TAG}
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:${IMAGE_TAG}
EOF
# notify:
# name: 🔔 Notify Deployment Result
# runs-on: ubuntu-latest
# needs: deploy
# if: always()
# steps:
# - name: Send Discord Notification
# run: |
# STATUS=${{ job.status }}
# MESSAGE="🚀 *Angular-Web-App Deployment* (${{ github.ref_name }}) finished with status: **${STATUS}**"
# curl -H "Content-Type: application/json" \
# -X POST \
# -d "{\"content\": \"${MESSAGE}\"}" \
# ${{ secrets.DISCORD_WEBHOOK_URL }}
# deploy-prod:
# if: startsWith(github.ref, 'refs/tags/')
# deploy-staging:
# if: github.ref == 'refs/heads/dev'