Skip to content

Frontend - connect with BE + update CI/CD (#152) #16

Frontend - connect with BE + update CI/CD (#152)

Frontend - connect with BE + update CI/CD (#152) #16

Workflow file for this run

name: Publish and deploy - Test Env.
on:
push:
tags:
- sprint-**-release-candidate
env:
REGISTRY: ghcr.io
IMAGE_NAME: amosproj/amos2024ss04-building-information-enhancer
jobs:
build-and-publish-frontend:
name: Build and publish the Frontend image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{github.ref_name}}
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{env.REGISTRY}}
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend
tags: |
type=ref,event=tag
type=sha
latest
- name: Build and Publish Docker Images
uses: docker/build-push-action@v5
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
tags: ${{steps.meta.outputs.tags}}
labels: ${{steps.meta.outputs.labels}}
build-and-publish-backend-api-gateway:
name: Build and publish - API Gateway
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{github.ref_name}}
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{env.REGISTRY}}
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-api-gateway
tags: |
type=ref,event=tag
type=sha
latest
- name: Build and Publish Docker Images
uses: docker/build-push-action@v5
with:
context: ./backend/src/BIE.Core
file: ./backend/src/BIE.Core/Dockerfile
push: true
tags: ${{steps.meta.outputs.tags}}
labels: ${{steps.meta.outputs.labels}}
build-and-publish-backend-datapipeline:
name: Build and publish - Data Pipeline
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{github.ref_name}}
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{env.REGISTRY}}
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-datapipeline
tags: |
type=ref,event=tag
type=sha
latest
- name: Build and Publish Docker Images
uses: docker/build-push-action@v5
with:
context: ./backend/src/BIE.DataPipeline
file: ./backend/src/BIE.DataPipeline/Dockerfile
push: true
tags: ${{steps.meta.outputs.tags}}
labels: ${{steps.meta.outputs.labels}}
build-and-publish-backend-sql-database:
name: Build and publish - SQL Database
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{github.ref_name}}
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{env.REGISTRY}}
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-sql-database
tags: |
type=ref,event=tag
type=sha
latest
- name: Build and Publish Docker Images
uses: docker/build-push-action@v5
with:
context: ./backend/database
file: ./backend/database/Dockerfile
push: true
tags: ${{steps.meta.outputs.tags}}
labels: ${{steps.meta.outputs.labels}}
deploy-test-env:
needs:
[
build-and-publish-frontend,
build-and-publish-backend-api-gateway,
build-and-publish-backend-datapipeline,
build-and-publish-backend-sql-database,
]
name: Deploy Docker Images in the Test Environment
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{github.ref_name}}
- name: Install SSH key
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{secrets.TEST_ENV_SSH_PRIVATE_KEY}}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{secrets.TEST_ENV_SSH_HOST}} > ~/.ssh/known_hosts
- name: Copy necessary files
run: |
scp ./docker-compose.yml ${{secrets.TEST_ENV_SSH_USER}}@${{secrets.TEST_ENV_SSH_HOST}}:/var/lib/bie
scp ./.env ${{secrets.TEST_ENV_SSH_USER}}@${{secrets.TEST_ENV_SSH_HOST}}:/var/lib/bie
- name: Connect and Pull
run: ssh ${{secrets.TEST_ENV_SSH_USER}}@${{secrets.TEST_ENV_SSH_HOST}} "cd /var/lib/bie && docker compose pull && docker compose up -d --remove-orphans && exit"
- name: Cleanup
run: rm -rf ~/.ssh