Skip to content

Commit 5a96bdd

Browse files
Run npm on GitHub so it is deployed into the Cloud site
1 parent 47f1588 commit 5a96bdd

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ on:
88
workflow_dispatch: # Allow manual triggering of the workflow
99

1010
jobs:
11-
12-
# Intentionally NOT syncing from Cloud as all patches/updates etc being done manually on GitHub repo
13-
1411
# Package and Deploy to Umbraco Cloud (without saving the artifact as contains sensitive data)
1512
cloud-deployment:
1613
name: "Deploy to Cloud"
@@ -23,4 +20,5 @@ jobs:
2320
formsLicenseKey: ${{ secrets.FORMS_LICENSE_KEY }}
2421
with:
2522
pathToWebsite: "src/OpenSourceTest.Site"
26-
csprojFile: "OpenSourceTest.Site.csproj"
23+
csprojFile: "OpenSourceTest.Site.csproj"
24+
pathToFrontendClient: "src/OpenSourceTest.MyExtension/Client"

.github/workflows/package-and-deploy.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
csprojFile:
1010
required: true
1111
type: string
12+
pathToFrontendClient:
13+
required: true
14+
type: string
1215

1316
secrets:
1417
projectId:
@@ -74,6 +77,20 @@ jobs:
7477
run: cp cloud.gitignore .gitignore
7578
shell: bash
7679

80+
# Setup Node.js for frontend build
81+
- name: Setup Node.js
82+
uses: actions/setup-node@v4
83+
with:
84+
node-version: '22.x'
85+
cache: 'npm'
86+
cache-dependency-path: '${{ inputs.pathToFrontendClient }}/package-lock.json'
87+
88+
# build the frontend assets
89+
- name: Build frontend assets
90+
working-directory: ${{ inputs.pathToFrontendClient }}
91+
run: npm ci && npm run build --if-present
92+
shell: bash
93+
7794
# zip everything, except what is defined in the 'cloud.zipignore'
7895
- name: Zip Source Code
7996
run: zip -r sources.zip . -x@cloud.zipignore

src/OpenSourceTest.MyExtension/OpenSourceTest.MyExtension.csproj

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,20 @@
3434
<Folder Include="wwwroot\" />
3535
</ItemGroup>
3636

37-
<!-- Restore and build Client files -->
38-
<Target Name="RestoreClient" Inputs="Client\package.json;Client\package-lock.json" Outputs="Client\node_modules\.package-lock.json">
37+
<!-- Restore and build Client files outside of Cloud environments -->
38+
<Target Name="RestoreClient"
39+
Inputs="Client\package.json;Client\package-lock.json"
40+
Outputs="Client\node_modules\.package-lock.json">
3941
<Message Importance="high" Text="Restoring Client NPM packages..." />
4042
<Exec Command="npm i" WorkingDirectory="Client" />
4143
</Target>
4244

43-
<Target Name="BuildClient" BeforeTargets="AssignTargetPaths" DependsOnTargets="RestoreClient" Inputs="@(ClientAssetsInputs)" Outputs="$(IntermediateOutputPath)client.complete.txt">
45+
<Target Name="BuildClient"
46+
BeforeTargets="AssignTargetPaths"
47+
DependsOnTargets="RestoreClient"
48+
Inputs="@(ClientAssetsInputs)"
49+
Outputs="$(IntermediateOutputPath)client.complete.txt"
50+
Condition="!('$(UMBRACO__CLOUD__ISRUNNINGONCLOUD)' == 'true' OR '$(ENVIRONMENT__PROJECTID)' != '')">
4451
<Message Importance="high" Text="Executing Client NPM build script..." />
4552
<Exec Command="npm run build" WorkingDirectory="Client" />
4653
<ItemGroup>

0 commit comments

Comments
 (0)