Skip to content

Commit

Permalink
Fix Continuous Integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Mtze authored and phnagy committed Jul 30, 2024
1 parent f4dc29d commit edb00a3
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 22 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ name: Build and Push

on:
pull_request:
push:
branches:
- develop
- main
tags: "[0-9]+.[0-9]+.[0-9]+"
# push:
# branches:
# - develop
# - main
# tags: "[0-9]+.[0-9]+.[0-9]+"
# TODO: Design a release workflow
release:
types:
- created
workflow_call:
outputs:
image_tag:
description: "The tag of the tease image that was built"
value: "${{ jobs.buildx.outputs.result }}"

jobs:
build-and-push:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build and Deploy to Dev

on:
push:
branches: [develop]

jobs:
build-dev-container:
uses: ./.github/workflows/build-and-push.yml
secrets: inherit
deploy-dev-container:
needs: build-dev-container
uses: ./.github/workflows/deploy-docker.yml
secrets: inherit
with:
environment: PROMPT-Dev
tease_image_tag: "develop"

37 changes: 26 additions & 11 deletions .github/workflows/deploy-docker.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: Deploy Docker Image

on:
workflow_run:
workflows: ["Build and Push"]
branches:
- main
- develop
types:
- completed
workflow_call:
inputs:
environment:
required: true
type: string
tease_image_tag:
default: "latest"
type: string

jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ (github.ref == 'refs/heads/main') && 'PROMPT-Prod' || (github.ref == 'refs/heads/develop') && 'PROMPT-Dev' }}
url: 'https://${{ vars.VM_HOST }}'
name: ${{ inputs.environment }}
url: "https://${{ vars.VM_HOST }}"
steps:
- name: SSH to VM and Execute Docker-Compose Down
uses: appleboy/[email protected]
Expand All @@ -28,7 +29,7 @@ jobs:
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: |
docker compose -f tease/docker-compose.prod.yml --env-file=.env.prod down --remove-orphans --rmi all
docker compose -f tease/docker-compose.prod.yml --env-file=.env.prod -env-file=tease/tease-env.prod down --remove-orphans --rmi all
- name: checkout
uses: actions/checkout@v4
Expand All @@ -46,6 +47,20 @@ jobs:
source: "./docker-compose.prod.yml"
target: /home/${{ vars.VM_USERNAME }}/tease

- name: SSH to VM and create .tease-env.prod file
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: |
touch tease/.tease-env.prod
echo "TEASE_IMAGE_TAG=${{ inputs.tease_image_tag }}" >> tease/.tease-env.prod
- name: SSH to VM and Execute Docker-Compose Up
uses: appleboy/[email protected]
with:
Expand All @@ -57,4 +72,4 @@ jobs:
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: |
docker compose -f tease/docker-compose.prod.yml --env-file=.env.prod up --pull=always -d
docker compose -f tease/docker-compose.prod.yml --env-file=.env.prod --env-file=tease/.tease-env.prod up --pull=always -d
18 changes: 18 additions & 0 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build and Deploy to Prod

on:
push:
branches: [main]

jobs:
build-prod-container:
uses: ./.github/workflows/build-and-push.yml
secrets: inherit
deploy-prod-container:
needs: build-prod-container
uses: ./.github/workflows/deploy-docker.yml
secrets: inherit
with:
environment: "PROMPT-Prod"
tease_image_tag: "latest"

4 changes: 2 additions & 2 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
tease:
image: ghcr.io/ls1intum/tease:latest
image: ghcr.io/ls1intum/tease:${TEASE_IMAGE_TAG:-latest}
container_name: tease
labels:
- "traefik.enable=true"
Expand All @@ -15,7 +15,7 @@ services:
- prompt-network

tease-server:
image: ghcr.io/ls1intum/tease-server:latest
image: ghcr.io/ls1intum/tease-server:${TEASE_IMAGE_TAG:-latest}
container_name: tease-server
labels:
- "traefik.enable=true"
Expand Down

0 comments on commit edb00a3

Please sign in to comment.