Skip to content

Fixed GHA contexts (#93) #8

Fixed GHA contexts (#93)

Fixed GHA contexts (#93) #8

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-push-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-push-backend:
name: Build and publish the Backend 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 }}-backend
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}}
deploy-test-env:
needs: [build-and-push-frontend, build-and-push-backend]
name: Deploy Docker Images in the Test Environment
runs-on: ubuntu-latest
steps:
- name: Install SSH keys
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: 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 && exit"
- name: Cleanup
run: rm -rf ~/.ssh