diff --git a/.github/workflows/deploy_production.yml b/.github/workflows/deploy_production.yml index 6fe2ffbc..40d27a7c 100644 --- a/.github/workflows/deploy_production.yml +++ b/.github/workflows/deploy_production.yml @@ -1,29 +1,89 @@ -name: Deploy - Production Env. +name: Publish and deploy - Production Env. on: push: tags: - sprint-**-release +env: + REGISTRY: ghcr.io + IMAGE_NAME: amosproj/amos2024ss04-building-information-enhancer + jobs: - PublishImages: - name: Publish Docker Images + build-and-push-frontend: + name: Builds and publishes the Frontend image runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Login - run: | - echo ${{secrets.PAT}} | docker login ghcr.io -u ${{github.actor}} --password-stdin - - name: Build and Publish - run: | - docker compose build --pull - docker-compose push - - name: Logout - run: docker logout + - 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: . + file: ./frontend/Dockerfile + push: true + tags: ${{steps.meta.outputs.tags}} + labels: ${{steps.meta.outputs.labels}} + + build-and-push-backend: + name: Builds and publishes 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: . + file: ./backend/Dockerfile + push: true + tags: ${{steps.meta.outputs.tags}} + labels: ${{steps.meta.outputs.labels}} - DeployProductionEnv: - needs: PublishImages + deploy-prod-env: + needs: [build-and-push-frontend, build-and-push-backend] name: Deploy Image in the Production Environment runs-on: ubuntu-latest diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml index 139294e8..7365dd58 100644 --- a/.github/workflows/deploy_test.yml +++ b/.github/workflows/deploy_test.yml @@ -1,30 +1,90 @@ -name: Deploy - Test Env. +name: Publish and deploy - Test Env. on: push: tags: - sprint-**-release-candidate +env: + REGISTRY: ghcr.io + IMAGE_NAME: amosproj/amos2024ss04-building-information-enhancer + jobs: - PublishImages: - name: Publish Docker Images + build-and-push-frontend: + name: Builds and publishes the Frontend image runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Login - run: | - echo ${{secrets.PAT}} | docker login ghcr.io -u ${{github.actor}} --password-stdin - - name: Build and Publish - run: | - docker compose build --pull - docker-compose push - - name: Logout - run: docker logout - - DeployTestEnv: - needs: PublishImages - name: Deploy Image in the Test Environment + - 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: . + file: ./frontend/Dockerfile + push: true + tags: ${{steps.meta.outputs.tags}} + labels: ${{steps.meta.outputs.labels}} + + build-and-push-backend: + name: Builds and publishes 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: . + file: ./backend/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: diff --git a/.github/workflows/frontend-CI.yml b/.github/workflows/frontend-CI.yml index 7b247076..8027af59 100644 --- a/.github/workflows/frontend-CI.yml +++ b/.github/workflows/frontend-CI.yml @@ -14,14 +14,13 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: - path: ~/.npm - key: npm-${{ hashFiles('package-lock.json') }} - restore-keys: npm- + path: ./frontend/node_modules + key: npm-dependencies-${{ hashFiles('./frontend/package-lock.json') }} - name: Setup frontend run: npm ci diff --git a/docker-compose.yml b/docker-compose.yml index a1250662..43c53fb1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: context: ./frontend dockerfile: Dockerfile container_name: react-frontend - image: ghcr.io/corgam/bie-frontend + image: ghcr.io/amosproj/amos2024ss04-building-information-enhancer-frontend environment: - HOST=${REACT_FRONTEND_HOST} - PORT=${REACT_FRONTEND_PORT} @@ -19,7 +19,7 @@ services: context: ./backend/src/BIE.Core dockerfile: Dockerfile container_name: backend - image: ghcr.io/corgam/bie-backend + image: ghcr.io/amosproj/amos2024ss04-building-information-enhancer-backend environment: - HOST=${BACKEND_HOST} - PORT=${BACKEND_PORT} diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 67cbe78b..adf61548 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,7 +1,7 @@ import "./App.css"; function App() { - return

Building Information Enhancer v.5

; + return

Building Information Enhancer v.6

; } export default App;