Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 39 additions & 32 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,53 @@
name: Build and Deploy to AWS
name: Build and Deploy to Azure
run-name: "Production Deployment #${{ github.run_number }}"

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

env:
JAR_FILENAME: Lobby-Platform
ARTIFACT_NAME: backend-app
SYSTEMD_SERVICE_NAME: lobby-platform

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
id-token: write # This is required for Azure login
contents: read # This is required for actions/checkout
packages: write # This is required for publishing the package

jobs:
build:
name: Build on GitHub
runs-on: ubuntu-latest
ci:
name: CI
uses: ./.github/workflows/template-ci-build.yml

deploy:
name: Deploy to Azure
runs-on: ubuntu-latest
needs: ci
environment: production
env:
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
AZURE_APPSVC_NAME: ${{ vars.AZURE_APPSVC_NAME }}
AZURE_RESOURCE_GROUP: ${{ vars.AZURE_RESOURCE_GROUP }}
steps:
# Checkout the repo
- name: git checkout
uses: actions/checkout@v3

# Setup JDK 17
- name: Set up JDK 17
uses: actions/setup-java@v3
# Az Login
- name: Az Login
uses: azure/login@v1
with:
java-version: '17'
distribution: 'corretto'

# Maven Verify
- name: Maven Verify
run: ./mvnw -B verify -DJAR_FILENAME=${{ env.JAR_FILENAME }}
client-id: ${{ env.AZURE_CLIENT_ID }}
tenant-id: ${{ env.AZURE_TENANT_ID }}
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}

# Dump GitHub Context
- name: Dump GitHub Context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
# Set App Service Image to Latest
- name: Set App Service Image to Latest
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$GITHUB_CONTEXT" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
az webapp config container set \
--name ${{ env.AZURE_APPSVC_NAME }} \
--resource-group ${{ env.AZURE_RESOURCE_GROUP }} \
--container-image-name ${{ needs.ci.outputs.image }}

az webapp restart \
--name ${{ env.AZURE_APPSVC_NAME }} \
--resource-group ${{ env.AZURE_RESOURCE_GROUP }}



14 changes: 14 additions & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: PR Build
run-name: "PR - Build #${{ github.run_number }}"

on:
pull_request:
branches:
- main

jobs:
ci:
name: CI
uses: ./.github/workflows/template-ci-build.yml
with:
push-image: false
78 changes: 78 additions & 0 deletions .github/workflows/template-ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Reusable Build Workflow

on:
workflow_call:
inputs:
push-image:
description: "Whether to push the Docker image to the registry"
required: false
type: boolean
default: true
outputs:
image:
description: "The full Docker image with registry/repository:tag"
value: ${{ jobs.build.outputs.image }}

env:
JAR_FILENAME: Lobby-Platform
JAR_OUTPUT_PATH: spring/target
DOCKERFILE_PATH: docker/Dockerfile
CONTAINER_REGISTRY: ${{ vars.CONTAINER_REGISTRY }}
CONTAINER_REPOSITORY: ${{ vars.CONTAINER_REPOSITORY }}

permissions:
contents: read # This is required for actions/checkout
packages: write # This is required for publishing the package

jobs:
build:
name: Build on GitHub
runs-on: ubuntu-latest
outputs:
image: ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_REPOSITORY }}:${{ github.sha }}
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Job outputs cannot reference workflow-level environment variables using env. The output value will be empty at runtime. Consider using a step output or directly referencing vars.CONTAINER_REGISTRY and vars.CONTAINER_REPOSITORY in the output expression.

Suggested change
image: ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_REPOSITORY }}:${{ github.sha }}
image: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_REPOSITORY }}:${{ github.sha }}

Copilot uses AI. Check for mistakes.

steps:
# Checkout the repo
- name: git checkout
uses: actions/checkout@v3

# Setup JDK 17
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "corretto"

# Maven Verify
- name: Maven Verify
run: ./mvnw -B verify -DJAR_FILENAME=${{ env.JAR_FILENAME }}

# Upload Artifact
- name: Upload Artifact
uses: actions/upload-artifact@v5
with:
name: jar-artifact
path: ${{ env.JAR_OUTPUT_PATH }}/${{ env.JAR_FILENAME }}.jar

# Docker Build
- name: Docker Build
shell: pwsh
run: docker build `
-t ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_REPOSITORY }}:${{ github.sha }} `
-f ${{ env.DOCKERFILE_PATH }} `
--build-arg JAR_FILENAME=${{ env.JAR_OUTPUT_PATH }}/${{ env.JAR_FILENAME }}.jar `
Comment on lines +59 to +63
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using PowerShell syntax (pwsh shell with backticks for line continuation) on ubuntu-latest is unconventional. The standard approach for multi-line commands on Linux runners is to use bash shell with backslashes. Consider changing to shell: bash and using backslashes (\) for line continuation.

Suggested change
shell: pwsh
run: docker build `
-t ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_REPOSITORY }}:${{ github.sha }} `
-f ${{ env.DOCKERFILE_PATH }} `
--build-arg JAR_FILENAME=${{ env.JAR_OUTPUT_PATH }}/${{ env.JAR_FILENAME }}.jar `
shell: bash
run: docker build \
-t ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_REPOSITORY }}:${{ github.sha }} \
-f ${{ env.DOCKERFILE_PATH }} \
--build-arg JAR_FILENAME=${{ env.JAR_OUTPUT_PATH }}/${{ env.JAR_FILENAME }}.jar \

Copilot uses AI. Check for mistakes.
.

# Login to GitHub Container Registry
- name: Login to GitHub Container Registry
if: ${{ inputs.push-image }}
uses: docker/login-action@v2
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Docker Push
- name: Docker Push
if: ${{ inputs.push-image }}
run: docker push ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_REPOSITORY }}:${{ github.sha }}