Merge pull request #13 from ls1intum/integrate-new-server #45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Chatbot | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# 1) Build for Org 2 | |
- name: Create Environment File (Org 2) | |
run: | | |
echo "export const environment = { | |
production: true, | |
angelosUrl: '/api/chat', | |
angelosAppApiKey: '${{secrets.ANGELOS_APP_API_KEY}}', | |
organisation: 2, | |
filterByOrg: true | |
};" > src/environments/environment.prod.ts | |
- name: Verify Environment File (Org 2) | |
run: test -f src/environments/environment.prod.ts || (echo "Environment file creation failed for org2." && exit 1) | |
- name: Build & Push (Org 2) | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: amd64, arm64 | |
file: ./Dockerfile | |
context: . | |
build-args: | | |
ANGULAR_CONFIG=production | |
tags: ghcr.io/ls1intum/angelos-ui:latest | |
push: true | |
no-cache: true | |
# 2) Build for Org 5 | |
- name: Create Environment File (Org 5) | |
run: | | |
echo "export const environment = { | |
production: true, | |
angelosUrl: '/api/chat', | |
angelosAppApiKey: '${{secrets.ANGELOS_APP_API_KEY}}', | |
organisation: 5, | |
filterByOrg: true | |
};" > src/environments/environment.prod.ts | |
- name: Verify Environment File (Org 5) | |
run: test -f src/environments/environment.prod.ts || (echo "Environment file creation failed for org5." && exit 1) | |
- name: Build & Push (Org 5) | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: amd64, arm64 | |
file: ./Dockerfile | |
context: . | |
build-args: | | |
ANGULAR_CONFIG=production-heilbronn | |
tags: ghcr.io/ls1intum/angelos-ui:org5-latest | |
push: true | |
no-cache: true | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Copy Docker Compose File From Repo to VM Host | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ vars.VM_HOST }} | |
username: ${{ vars.VM_USERNAME }} | |
key: ${{ secrets.VM_SSH_PRIVATE_KEY }} | |
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }} | |
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }} | |
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }} | |
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }} | |
source: "./docker-compose.yml" | |
target: /home/${{ vars.VM_USERNAME }}/${{ github.repository }} | |
- name: SSH to VM and Execute Docker-Compose Up | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ vars.VM_HOST }} | |
username: ${{ vars.VM_USERNAME }} | |
key: ${{ secrets.VM_SSH_PRIVATE_KEY }} | |
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }} | |
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }} | |
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }} | |
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }} | |
script: | | |
if ! docker network inspect angelos-network >/dev/null 2>&1; then | |
echo "Network 'angelos-network' does not exist, creating it..." | |
docker network create angelos-network | |
fi | |
docker network ls | |
docker compose -f /home/${{ vars.VM_USERNAME }}/${{ github.repository }}/docker-compose.yml up --pull=always -d --force-recreate --remove-orphans |