Skip to content

Commit 35532c3

Browse files
committed
Added Build
1 parent 6dcc9c2 commit 35532c3

File tree

3 files changed

+131
-0
lines changed

3 files changed

+131
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Deploy - Accounts
2+
on:
3+
push:
4+
branches: [ main ]
5+
paths:
6+
- 'src/SourceSchemas/Accounts/**'
7+
- '.github/workflows/deploy-accounts.yml'
8+
workflow_dispatch: {}
9+
10+
jobs:
11+
deploy:
12+
uses: ./.github/workflows/deploy-source-schema.yml
13+
with:
14+
app_name: ccc-eu-fusion-demo-accounts-api
15+
project_path: src/SourceSchemas/Accounts
16+
container_port: 8080
17+
schema_file: ./src/SourceSchemas/Accounts/schema.graphqls
18+
secrets: inherit
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: deploy-source-schema
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
app_name:
7+
description: Name of the Container App + repo path in ACR
8+
required: true
9+
type: string
10+
project_path:
11+
description: Path to the .csproj folder
12+
required: true
13+
type: string
14+
container_port:
15+
description: App port exposed in the container
16+
required: false
17+
type: number
18+
default: 8080
19+
schema_file:
20+
description: Source Schema File
21+
required: true
22+
type: string
23+
secrets:
24+
AZURE_CREDENTIALS: { required: true }
25+
AZURE_SUBSCRIPTION_ID: { required: true }
26+
AZURE_RESOURCE_GROUP: { required: true }
27+
CONTAINERAPPS_ENVIRONMENT: { required: true }
28+
ACR_LOGIN_SERVER: { required: true }
29+
ACR_USERNAME: { required: true }
30+
ACR_PASSWORD: { required: true }
31+
NITRO_API_KEY: { required: true }
32+
NITRO_API_ID: { required: true }
33+
NITRO_STAGE: { required: true }
34+
35+
jobs:
36+
build-publish-deploy:
37+
runs-on: ubuntu-latest
38+
concurrency:
39+
group: deploy-${{ inputs.app_name }}
40+
cancel-in-progress: false
41+
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
46+
- name: Setup .NET 9 SDK
47+
uses: actions/setup-dotnet@v4
48+
with:
49+
dotnet-version: 9.0.x
50+
51+
- name: Azure login
52+
uses: azure/login@v2
53+
with:
54+
creds: ${{ secrets.AZURE_CREDENTIALS }}
55+
56+
- name: ACR login (for dotnet publish push)
57+
uses: docker/login-action@v3
58+
with:
59+
registry: ${{ secrets.ACR_LOGIN_SERVER }}
60+
username: ${{ secrets.ACR_USERNAME }}
61+
password: ${{ secrets.ACR_PASSWORD }}
62+
63+
- name: Compute image tag
64+
id: meta
65+
run: |
66+
TS=$(date -u +'%Y%m%dT%H%M%SZ')
67+
SHORTSHA=${GITHUB_SHA::7}
68+
echo "tag=${TS}-${SHORTSHA}" >> $GITHUB_OUTPUT
69+
echo "image=${{ secrets.ACR_LOGIN_SERVER }}/${{ inputs.app_name }}:${TS}-${SHORTSHA}" >> $GITHUB_OUTPUT
70+
71+
# Build .NET app and publish directly to an OCI image, then push to ACR.
72+
- name: dotnet publish -> container (push to ACR)
73+
working-directory: ${{ inputs.project_path }}
74+
run: |
75+
dotnet restore
76+
dotnet publish -c Release \
77+
-p:PublishProfile=DefaultContainer \
78+
-p:ContainerRepository=${{ inputs.app_name }} \
79+
-p:ContainerImageTag=${{ steps.meta.outputs.tag }} \
80+
-p:ContainerRegistry=${{ secrets.ACR_LOGIN_SERVER }} \
81+
-p:ContainerPort=${{ inputs.container_port }} \
82+
-p:ContainerBaseImage=mcr.microsoft.com/dotnet/aspnet:9.0
83+
84+
- name: Deploy to Azure Container Apps
85+
uses: azure/container-apps-deploy-action@v2
86+
with:
87+
containerAppName: ${{ inputs.app_name }}
88+
resourceGroup: ${{ secrets.AZURE_RESOURCE_GROUP }}
89+
imageToDeploy: ${{ steps.meta.outputs.image }}
90+
environment: ${{ secrets.CONTAINERAPPS_ENVIRONMENT }}
91+
targetPort: ${{ inputs.container_port }}
92+
ingress: external
93+
registryUrl: ${{ secrets.ACR_LOGIN_SERVER }}
94+
registryUsername: ${{ secrets.ACR_USERNAME }}
95+
registryPassword: ${{ secrets.ACR_PASSWORD }}
96+
97+
- name: Publish Gateway Schema
98+
uses: ChilliCream/nitro-fusion-publish-action@v1.1
99+
with:
100+
tag: ${{ steps.meta.outputs.tag }}
101+
stage: ${{ secrets.NITRO_STAGE }}
102+
api-id: ${{ secrets.NITRO_API_ID }}
103+
api-key: ${{ secrets.NITRO_API_KEY }}
104+
source-schema-file: ${{ inputs.schema_file }}
105+
nitro-version: '16.0.0-p.7.52'
106+
working-directory: './'

src/SourceSchemas/Accounts/Demo.Accounts.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<ContainerPort>8080</ContainerPort>
6+
<ContainerBaseImage>mcr.microsoft.com/dotnet/aspnet:9.0</ContainerBaseImage>
7+
<PublishProfile>DefaultContainer</PublishProfile>
8+
</PropertyGroup>
29

310
<ItemGroup Condition="'$(ImplicitUsings)' == 'enable'">
411
<Using Include="Demo.Accounts"/>

0 commit comments

Comments
 (0)