Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/terraform workflows #90

Merged
merged 65 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
86469d3
restructed application
simonjfirth May 3, 2024
6c8fad8
added contentful
simonjfirth May 3, 2024
d1c257b
Updated packages
simonjfirth May 3, 2024
8c68c25
Bundled DfE FE with application
simonjfirth May 3, 2024
22b623d
Added Contentful
May 7, 2024
5259fb8
updated page to call Contentful
May 7, 2024
f89ecde
Update page model
jack-coggin May 8, 2024
d99f973
Added dependencyInjection Extension
May 8, 2024
7ee28d8
General cleanup/ clutter removal
May 8, 2024
a567031
Added sitemap
May 8, 2024
7c635b6
merged
May 8, 2024
c36aa46
More cleanup
May 8, 2024
4779ee9
Merged
May 8, 2024
f78d11b
Merge cleanup
May 8, 2024
a8c61dd
Removed some magic strings
May 8, 2024
cc0e4e5
Merge pull request #74 from DFE-Digital/feature/_rework/cleanup
ThomasWhittington May 8, 2024
6d38436
Pulled getEntries out
May 8, 2024
c0d428f
Added test project
May 9, 2024
9a4af93
Added ADR docs
May 13, 2024
75c19a1
Added basic unit tests
May 13, 2024
adc78b6
Merge pull request #76
ThomasWhittington May 13, 2024
a36deae
added ADR
May 13, 2024
3b65640
merge
May 13, 2024
f7178c5
Merge pull request #78 from DFE-Digital/feature/adr
simonjfirth May 13, 2024
d8efabd
updated folder structure
May 13, 2024
75d03ee
restructure
May 13, 2024
1477325
Added architecture diagram
May 13, 2024
3d68674
More unit tests
May 15, 2024
d1eb7aa
Added DI test
May 15, 2024
15e4490
Merge pull request #79 from DFE-Digital/feature/_rework/testing
ThomasWhittington May 15, 2024
3907b0e
Added contentful model for richtext
May 20, 2024
c7439e2
Merge pull request #81 from DFE-Digital/feature/_rework/model
ThomasWhittington May 20, 2024
e7c0a4c
Updated content service (#82)
ThomasWhittington May 23, 2024
b882a40
Created contentful stub
May 24, 2024
6e8a5fc
Updated to query builder
May 24, 2024
2bd2621
Add renderer for rich text content (#75)
jack-coggin May 24, 2024
6b5894d
updated e2e and app settings
May 24, 2024
4b53768
Merge remote-tracking branch 'origin/feature/rework' into feature/con…
May 24, 2024
748461f
Merge pull request #84 from DFE-Digital/feature/contentful-stub
simonjfirth May 24, 2024
6b75869
Updated tests
ThomasWhittington May 28, 2024
650977f
Feature/ rework/linking (#86)
ThomasWhittington May 30, 2024
7363e0a
wip: render linked entry and asset from within rich text
jack-coggin Jun 6, 2024
8cc086a
wip: render download component
jack-coggin Jun 6, 2024
02e3b0c
display corresponding icon for download filetype
jack-coggin Jun 7, 2024
cf133a6
update e2e tests
jack-coggin Jun 10, 2024
99967c2
Feature/ rework/embedded entries (#87)
ThomasWhittington Jun 11, 2024
75bd6a4
Merge branch 'feature/rework' into feature/download-component
jack-coggin Jun 11, 2024
6c737cd
update entry partial
jack-coggin Jun 11, 2024
b6a448d
revert ContentService changes
jack-coggin Jun 11, 2024
7c18842
use target variable in entry partial
jack-coggin Jun 12, 2024
8b47734
tweak entry partial
jack-coggin Jun 12, 2024
546824d
update file icons
jack-coggin Jun 12, 2024
c9f083d
Merge pull request #88 from DFE-Digital/feature/download-component
jack-coggin Jun 12, 2024
cebefc2
Added terraform scripts
Jun 13, 2024
6fbd22e
Added workflows and actions
Jun 13, 2024
f15d4cc
adding missing WAF and updated contentful environment
Jun 13, 2024
0b54167
updated workflow
simonjfirth Jun 17, 2024
6845b17
TF changes to get inital build going
Iain-Stanger Jun 18, 2024
c142aee
merge
Iain-Stanger Jun 18, 2024
ffeccc6
fixed tflint
simonjfirth Jun 18, 2024
a9ecc9b
removed unused vars from pr-check
simonjfirth Jun 18, 2024
8420f2f
added dev environment
simonjfirth Jun 18, 2024
51c7c07
lock updated
simonjfirth Jun 18, 2024
d976dd5
reformatted locals.tf
simonjfirth Jun 18, 2024
584e98f
terraform-docs: automated action
github-actions[bot] Jun 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 17 additions & 0 deletions .dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /
COPY src/ src/
RUN dotnet publish "src/Dfe.ContentSupport.Web/Dfe.ContentSupport.Web.csproj" -c Release -o /out/publish
RUN rm -rf /src

FROM base AS final
WORKDIR /src
RUN useradd -m dotnet
COPY --from=build /out/publish .
RUN chown dotnet:dotnet /src .
USER dotnet
ENTRYPOINT ["dotnet", "Dfe.ContentSupport.Web.dll"]
42 changes: 42 additions & 0 deletions .github/actions/azure-ip-whitelist/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Azure IP Whitelist
description: Add or remove an IP Address to the Azure KV + SQL whitelist

inputs:
ip_address:
required: true
type: string
verb:
required: true
type: choice
options:
- "add"
- "remove"
az_resource_group:
required: true
type: string
az_keyvault_name:
required: true
type: string
az_ip_name:
type: string
default: "github_action"
az_sql_database_server_name:
required: true
type: string

runs:
using: composite
steps:
- name: Add to whitelist
if: ${{ inputs.verb == 'add' }}
shell: bash
run: |
az keyvault network-rule add --resource-group ${{ inputs.az_resource_group }} --name ${{ inputs.az_keyvault_name }} --ip-address ${{ inputs.ip_address }} &> /dev/null
az sql server firewall-rule create --resource-group ${{ inputs.az_resource_group }} --server ${{ inputs.az_sql_database_server_name }} --name ${{ inputs.az_ip_name }} --start-ip-address ${{ inputs.ip_address }} --end-ip-address ${{ inputs.ip_address }} &> /dev/null

- name: Remove from whitelist
if: ${{ inputs.verb == 'remove' }}
shell: bash
run: |
az keyvault network-rule remove --resource-group ${{ inputs.az_resource_group }} --name ${{ inputs.az_keyvault_name }} --ip-address ${{ inputs.ip_address }} &> /dev/null
az sql server firewall-rule delete --resource-group ${{ inputs.az_resource_group }} --server ${{ inputs.az_sql_database_server_name }} --name ${{ inputs.az_ip_name }} &> /dev/null
4 changes: 1 addition & 3 deletions .github/actions/azure-login/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ runs:
- name: Azure login with ACA credentials
uses: azure/login@v1
with:
creds: '{"clientId":"${{ inputs.az_client_id }}","clientSecret":"${{ inputs.az_client_secret }}","subscriptionId":"${{ inputs.az_subscription_id }}","tenantId":"${{ inputs.az_tenant_id }}"}'

#test
creds: '{"clientId":"${{ inputs.az_client_id }}","clientSecret":"${{ inputs.az_client_secret }}","subscriptionId":"${{ inputs.az_subscription_id }}","tenantId":"${{ inputs.az_tenant_id }}"}'
10 changes: 10 additions & 0 deletions .github/actions/build-docker-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Build Docker Image
description: Builds the docker image

runs:
using: composite

steps:
- name: Build Docker image
shell: bash
run: docker build ./src/ --file ./.dockerfile --tag dfe-digital_sts-content-and-support:$(date +%s)
25 changes: 25 additions & 0 deletions .github/actions/build-dotnet-app/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build DotNet App
description: Sets up .Net for specified version and builds application

inputs:
dotnet_version:
required: true
type: string
solution_filename:
required: true
type: string

runs:
using: composite

steps:
- name: Setup .NET Core SDK ${{ inputs.dotnet_version }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ inputs.dotnet_version }}
- name: Install dependencies
shell: bash
run: dotnet restore ${{ inputs.solution_filename }}
- name: Build
shell: bash
run: dotnet build ${{ inputs.solution_filename }} --configuration Release --no-restore --output ./build
24 changes: 24 additions & 0 deletions .github/actions/list-directory/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: List Directory
description: Get a list of folders from a given input source directory as a JSON array.

inputs:
source:
required: true
type: string
outputs:
directories:
value: ${{ steps.list-dir.outputs.directories }}

runs:
using: composite

steps:
- name: Get List of Directories
id: list-dir
shell: bash
run: |
cd ${{ inputs.source }}
array=(*/)
directories="$(jq -c -n '$ARGS.positional' --args "${array[@]}")"
echo $directories
echo "directories=$directories" >> $GITHUB_OUTPUT
92 changes: 92 additions & 0 deletions .github/actions/post-terraform-results/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Post Terraform Results
description: Updates the PR with the Terraform results

inputs:
github_token:
required: true
type: string
plan_stdout:
required: true
type: string
plan_outcome:
required: true
type: string
fmt_outcome:
required: true
type: string
init_outcome:
required: true
type: string
validate_outcome:
required: true
type: string
validate_stdout:
required: true
type: string
github_actor:
required: true
type: string
github_event_name:
required: true
type: string
tf_working_directory:
required: true
type: string
github_workflow:
required: true
type: string

runs:
using: composite

steps:
- name: Update PR with Terraform results
uses: actions/github-script@v7
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ inputs.plan_stdout }}"
with:
github-token: ${{ inputs.github_token }}
script: |
// 1. Retrieve existing bot comments for the PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
const botComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes('Terraform Format and Style')
})

// 2. Prepare format of the comment
const output = `#### Terraform Format and Style 🖌\`${{ inputs.fmt_outcome }}\`
#### Terraform Initialization ⚙️\`${{ inputs.init_outcome }}\`
#### Terraform Validation 🤖\`${{ inputs.validate_outcome }}\`
<details><summary>Validation Output</summary>

\`\`\`\n
${{ inputs.validate_stdout }}
\`\`\`

</details>

#### Terraform Plan 📖\`${{ inputs.plan_outcome }}\`

*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.TF_WORKING_DIRECTORY }}\`, Workflow: \`${{ github.workflow }}\`*`;

// 3. If we have a comment, update it, otherwise create a new one
if (botComment) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: output
})
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
}
23 changes: 23 additions & 0 deletions .github/actions/run-unit-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run Unit Tests
description: Runs the unit tests and publishes them to the workflow runs

inputs:
solution_filename:
required: true
type: string

runs:
using: composite

steps:
- name: Test
shell: bash
run: dotnet test ${{ inputs.solution_filename }} --no-restore --verbosity normal --collect:"XPlat Code Coverage" --logger:"trx;LogFileName=test-results.trx" || true
- name: Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: DotNET Tests
path: "**/test-results.trx"
reporter: dotnet-trx
fail-on-error: true
16 changes: 16 additions & 0 deletions .github/semver-release/.releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/github",
{
"successComment": false
}
]
],
"branches": [
{ "name": "main" },
{ "name": "development", "prerelease": true }
]
}
Loading