Skip to content

Commit 793c138

Browse files
Fix Bug
Fix an issue where the publish command sequence was not executing properly. Separated out the test commands into their own job so that the build command has a clean workspace free from clutter from the testing. This also reduces the permissions needed when running the test commands, reducing surface area for attack.
1 parent 5735abe commit 793c138

File tree

1 file changed

+44
-15
lines changed

1 file changed

+44
-15
lines changed

.github/workflows/NPM-Publish.yml

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@ on:
1010
# Define each session of execution that should be executed
1111
jobs:
1212
# Execution session that builds the artifacts that are used for deployment
13-
Build-Artifact:
13+
Test-Artifact:
1414
# Display name of the job
15-
name: Build Artifact
15+
name: Test Artifact
1616

1717
# Configures the filter for which operating system that should be used when selecting runners
1818
runs-on: ubuntu-latest
19-
20-
# Sets the scopes available to the github_token injected to the GH Actions runner
21-
permissions:
22-
attestations: write
23-
contents: read
24-
id-token: write
2519

2620
# Set of commands to run for the build job
2721
steps:
@@ -61,7 +55,7 @@ jobs:
6155

6256
# Compile the Typescript files to JS
6357
- name: Build Project in Development Mode
64-
run: npm run-script build:Prod
58+
run: npm run-script build:Dev
6559

6660
# Run all of the Unit Tests
6761
- name: Runt Unit Tests
@@ -71,9 +65,44 @@ jobs:
7165
- name: Run Lint Tests
7266
run: npm run-script lint
7367

74-
# Install all of the production only dependencies
75-
- name: Clear All but Runtime Dependencies
76-
run: npm ci --omit=dev
68+
# Execution session that builds the artifacts that are used for deployment
69+
Build-Artifact:
70+
# Display name of the job
71+
name: Build Artifact
72+
73+
# Configures the filter for which operating system that should be used when selecting runners
74+
runs-on: ubuntu-latest
75+
76+
# Require the build step to complete before running the deployment
77+
needs: Test-Artifact
78+
79+
# Sets the scopes available to the github_token injected to the GH Actions runner
80+
permissions:
81+
attestations: write
82+
contents: read
83+
id-token: write
84+
85+
# Set of commands to run for the build job
86+
steps:
87+
# Checks-out your repository under $GITHUB_WORKSPACE
88+
- name: Clone Repo
89+
uses: actions/checkout@v4
90+
91+
# Set up NodeJS on the build host with caching support to optimize execution
92+
- name: Set up Node.js
93+
uses: actions/setup-node@v4
94+
with:
95+
node-version: 20.x
96+
cache: npm
97+
cache-dependency-path: package-lock.json
98+
99+
# Install all of the dependencies
100+
- name: Install All of the Project Dependencies
101+
run: npm install
102+
103+
# Compile the Typescript files to JS
104+
- name: Build Project in Development Mode
105+
run: npm run-script build:Prod
77106

78107
# Create a ZIP archive of the server files to speed up the upload process
79108
- name: Zip up Server Files
@@ -103,14 +132,14 @@ jobs:
103132
# Configures the filter for which operating system that should be used when selecting runners
104133
runs-on: ubuntu-latest
105134

135+
# Require the build step to complete before running the deployment
136+
needs: Build-Artifact
137+
106138
# Sets the scopes available to the github_token injected to the GH Actions runner
107139
permissions:
108140
id-token: write
109141
contents: none
110142

111-
# Require the build step to complete before running the deployment
112-
needs: Build-Artifact
113-
114143
# The deploy step runs in the Azure environment context
115144
environment: NPM
116145

0 commit comments

Comments
 (0)