CI Test
Some checks failed
Build, Push & Deploy Angular App / ⬆️ Build and Push Image to Gitea Registry (push) Has been cancelled
Build, Push & Deploy Angular App / 🚀 Deploy to Remote Server (push) Has been cancelled

This commit is contained in:
Murat Özkorkmaz
2025-10-17 18:08:47 +02:00
parent a1a499f877
commit 329ffafd5a

View File

@@ -7,13 +7,23 @@ on:
tags: tags:
- '*' - '*'
env:
IMAGE_NAME: ${{ vars.IMAGE_NAME }}
GITEA_REGISTRY: ${{ vars.IMAGE_REGISTRY }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
CI_REGISTRY_USER: ${{ secrets.CI_REGISTRY_USER }}
CI_REGISTRY_PASSWORD: ${{ secrets.CI_REGISTRY_PASSWORD }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
TAG: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }}
jobs: jobs:
# build: # build:
# name: 🏗️ Build Docker Image # name: 🏗️ Build Docker Image
# runs-on: ubuntu-latest # runs-on: ubuntu-latest
# steps: # steps:
# - name: Checkout Repository # - uses: actions/checkout@v3
# uses: actions/checkout@v3
# #
# - name: Install Docker client # - name: Install Docker client
# run: | # run: |
@@ -24,19 +34,14 @@ jobs:
# run: | # run: |
# chmod +x ./docker/build.sh # chmod +x ./docker/build.sh
# cd docker # cd docker
# ./build.sh "${{ env.IMAGE_NAME }}" "${{ env.TAG }}" # ./build.sh "${IMAGE_NAME}" "${TAG}"
#
# env:
# IMAGE_NAME: angular-web-app
# TAG: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }}
push: push:
name: ⬆️ Build and Push Image to Gitea Registry name: ⬆️ Build and Push Image to Gitea Registry
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
steps: steps:
- name: Checkout Repository - uses: actions/checkout@v3
uses: actions/checkout@v3
- name: Build and Push Image - name: Build and Push Image
run: | run: |
@@ -44,15 +49,10 @@ jobs:
sudo apt-get install -y docker.io bash sudo apt-get install -y docker.io bash
cd docker cd docker
chmod +x ./push-to-gitea.sh chmod +x ./push-to-gitea.sh
export GITEA_REGISTRY="${{ env.GITEA_REGISTRY }}" export GITEA_REGISTRY="${GITEA_REGISTRY}"
export GITEA_USER="${{ secrets.CI_REGISTRY_USER }}" export GITEA_USER="${CI_REGISTRY_USER}"
export GITEA_TOKEN="${{ secrets.CI_REGISTRY_PASSWORD }}" export GITEA_TOKEN="${CI_REGISTRY_PASSWORD}"
./push-to-gitea.sh "${{ env.IMAGE_NAME }}" "${{ env.TAG }}" ./push-to-gitea.sh "${IMAGE_NAME}" "${TAG}"
env:
IMAGE_NAME: angular-web-app
TAG: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }}
GITEA_REGISTRY: gitea.moz-tech.de
deploy: deploy:
name: 🚀 Deploy to Remote Server name: 🚀 Deploy to Remote Server
@@ -67,18 +67,17 @@ jobs:
- name: Deploy via SSH - name: Deploy via SSH
run: | run: |
IMAGE_TAG="${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }}" echo "${DEPLOY_KEY}" > /tmp/deploy_key.pem
echo "${{ secrets.DEPLOY_KEY }}" > /tmp/deploy_key.pem
chmod 600 /tmp/deploy_key.pem chmod 600 /tmp/deploy_key.pem
ssh -i /tmp/deploy_key.pem -o StrictHostKeyChecking=no \ ssh -i /tmp/deploy_key.pem -o StrictHostKeyChecking=no \
${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} <<EOF ${DEPLOY_USER}@${DEPLOY_HOST} <<EOF
docker login gitea.moz-tech.de -u "${{ secrets.CI_REGISTRY_USER }}" -p "${{ secrets.CI_REGISTRY_PASSWORD }}" docker login ${GITEA_REGISTRY} -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}"
docker pull gitea.moz-tech.de/${{ secrets.CI_REGISTRY_USER }}/angular-web-app:${IMAGE_TAG} docker pull ${GITEA_REGISTRY}/${CI_REGISTRY_USER}/${IMAGE_NAME}:${TAG}
docker stop angular-web-app || true docker stop ${IMAGE_NAME} || true
docker rm angular-web-app || true docker rm ${IMAGE_NAME} || true
docker run -d --name angular-web-app -p 80:80 gitea.moz-tech.de/${{ secrets.CI_REGISTRY_USER }}/angular-web-app:${IMAGE_TAG} docker run -d --name ${IMAGE_NAME} -p 80:80 ${GITEA_REGISTRY}/${CI_REGISTRY_USER}/${IMAGE_NAME}:${TAG}
EOF EOF
# notify: # notify:
# name: 🔔 Notify Deployment Result # name: 🔔 Notify Deployment Result