diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b926172..55c6b29 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,35 +1,31 @@ name: Deploy to environment -# Manual deployment only - user must select application and environment on: + push: + branches: + - main workflow_dispatch: inputs: - application: - type: choice - description: "Choose an application to deploy" - required: true - options: - - Transfers - - Lsrp - - RGVisits environment: - type: choice + type: environment description: "Choose an environment to deploy to" required: true - options: - - development - - test - - production concurrency: - group: ${{ github.workflow }}-${{ github.event.inputs.application }}-${{ github.event.inputs.environment }}-${{ github.run_number }} + group: ${{ github.workflow }}-${{ github.event.inputs.environment }}-${{ github.run_number }} + +env: + IMAGE_NAME: flexformsweb + +permissions: + contents: read + packages: read jobs: set-env: name: Preflight runs-on: ubuntu-24.04 outputs: - application: ${{ steps.var.outputs.application }} environment: ${{ steps.var.outputs.environment }} branch: ${{ steps.var.outputs.branch }} checked-out-sha: ${{ steps.var.outputs.checked-out-sha }} @@ -42,21 +38,10 @@ jobs: run: | GIT_REF=${{ github.ref_name }} GIT_BRANCH=${GIT_REF##*/} - - # Get application and environment from workflow inputs (required) - APPLICATION="${{ github.event.inputs.application }}" ENVIRONMENT="${{ github.event.inputs.environment }}" - - # Construct GitHub Environment name: transfers-development, lsrp-production, etc. - GITHUB_ENVIRONMENT="${APPLICATION,,}-${ENVIRONMENT,,}" - - # Construct image name: extapp-transfers, extapp-lsrp, etc. - IMAGE_NAME="extapp-${APPLICATION,,}" - CHECKED_OUT_SHA="$(git log -1 '--format=format:%H')" - - echo "application=${APPLICATION}" >> $GITHUB_OUTPUT echo "environment=${GITHUB_ENVIRONMENT}" >> $GITHUB_OUTPUT + echo "environment-lower=${ENVIRONMENT,,}" >> $GITHUB_OUTPUT echo "branch=$GIT_BRANCH" >> $GITHUB_OUTPUT echo "checked-out-sha=${CHECKED_OUT_SHA}" >> $GITHUB_OUTPUT echo "image-name=${IMAGE_NAME}" >> $GITHUB_OUTPUT diff --git a/Dockerfile b/Dockerfile index 411d4bf..f1d5b1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,8 @@ # Set the major version of dotnet ARG DOTNET_VERSION=10.0 -# Application to build (Transfers, Lsrp, etc.) - determines which configuration folder to use -ARG APPLICATION=Transfers # Stage 1 - Build the app using the dotnet SDK FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-azurelinux3.0 AS build -ARG APPLICATION WORKDIR /build # Copy the solution file and source code @@ -19,21 +16,11 @@ RUN --mount=type=secret,id=github_token \ dotnet build GovUK.Dfe.FlexForms.Web.sln --no-restore -c Release && \ dotnet publish GovUK.Dfe.FlexForms.Web.sln --no-build -o /app -# Copy application-specific configuration to the published output -# The configurations folder is already inside the Web project and gets published -# But we ensure only the specific application's config is in the final image -RUN mkdir -p /app/configurations/${APPLICATION} && \ - cp -f ./src/GovUK.Dfe.FlexForms.Web/configurations/${APPLICATION}/appsettings*.json /app/configurations/${APPLICATION}/ - # Stage 2 - Build a runtime environment FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION}-azurelinux3.0 AS final -ARG APPLICATION WORKDIR /app -LABEL org.opencontainers.image.source="https://github.com/DFE-Digital/external-applications-web" -LABEL org.opencontainers.image.description="External Applications - App" - -# Set the application name environment variable for runtime configuration loading -ENV APPLICATION_NAME=${APPLICATION} +LABEL org.opencontainers.image.source="https://github.com/DFE-Digital/flexforms-web" +LABEL org.opencontainers.image.description="Flexforms - Web" COPY --from=build /app /app COPY ./script/web-docker-entrypoint.sh /app/docker-entrypoint.sh