Skip to content

Commit 0b27c71

Browse files
committed
Generate and use action-versions.ts
1 parent 6679b04 commit 0b27c71

File tree

2 files changed

+47
-6
lines changed

2 files changed

+47
-6
lines changed

pr-checks/action-versions.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
export const ACTION_VERSIONS = {
2+
"actions/checkout": {
3+
"version": "v6"
4+
},
5+
"actions/setup-go": {
6+
"version": "v6"
7+
},
8+
"actions/setup-dotnet": {
9+
"version": "v5"
10+
},
11+
"actions/upload-artifact": {
12+
"version": "v7"
13+
},
14+
"actions/github-script": {
15+
"version": "v8"
16+
},
17+
"actions/setup-python": {
18+
"version": "v6"
19+
},
20+
"actions/setup-java": {
21+
"version": "v5"
22+
},
23+
"actions/setup-node": {
24+
"version": "v6"
25+
},
26+
"ruby/setup-ruby": {
27+
"version": "09a7688d3b55cf0e976497ff046b70949eeaccfd",
28+
"comment": " v1.288.0"
29+
}
30+
};

pr-checks/sync.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import * as path from "path";
55

66
import * as yaml from "yaml";
77

8+
import { ACTION_VERSIONS } from "./action-versions";
9+
810
/** Known workflow input names. */
911
enum KnownInputName {
1012
GoVersion = "go-version",
@@ -13,6 +15,9 @@ enum KnownInputName {
1315
DotnetVersion = "dotnet-version",
1416
}
1517

18+
/** Known Action names that we have version information for. */
19+
type KnownAction = keyof typeof ACTION_VERSIONS;
20+
1621
/**
1722
* Represents workflow input definitions.
1823
*/
@@ -94,6 +99,12 @@ const THIS_DIR = __dirname;
9499
const CHECKS_DIR = path.join(THIS_DIR, "checks");
95100
const OUTPUT_DIR = path.join(THIS_DIR, "..", ".github", "workflows");
96101

102+
/** Gets an `actionName@ref` string for `actionName`. */
103+
function getActionRef(actionName: KnownAction): string {
104+
const versionInfo = ACTION_VERSIONS[actionName];
105+
return `${actionName}@${versionInfo.version}`;
106+
}
107+
97108
/**
98109
* Loads and parses a YAML file.
99110
*/
@@ -216,7 +227,7 @@ function main(): void {
216227
const steps: any[] = [
217228
{
218229
name: "Check out repository",
219-
uses: "actions/checkout@v6",
230+
uses: getActionRef("actions/checkout"),
220231
},
221232
];
222233

@@ -226,7 +237,7 @@ function main(): void {
226237
steps.push(
227238
{
228239
name: "Install Node.js",
229-
uses: "actions/setup-node@v6",
240+
uses: getActionRef("actions/setup-node"),
230241
with: {
231242
"node-version": "20.x",
232243
cache: "npm",
@@ -265,7 +276,7 @@ function main(): void {
265276

266277
steps.push({
267278
name: "Install Go",
268-
uses: "actions/setup-go@v6",
279+
uses: getActionRef("actions/setup-go"),
269280
with: {
270281
"go-version":
271282
"${{ inputs.go-version || '" + baseGoVersionExpr + "' }}",
@@ -289,7 +300,7 @@ function main(): void {
289300

290301
steps.push({
291302
name: "Install Java",
292-
uses: "actions/setup-java@v5",
303+
uses: getActionRef("actions/setup-java"),
293304
with: {
294305
"java-version":
295306
"${{ inputs.java-version || '" + baseJavaVersionExpr + "' }}",
@@ -312,7 +323,7 @@ function main(): void {
312323
steps.push({
313324
name: "Install Python",
314325
if: "matrix.version != 'nightly-latest'",
315-
uses: "actions/setup-python@v6",
326+
uses: getActionRef("actions/setup-python"),
316327
with: {
317328
"python-version":
318329
"${{ inputs.python-version || '" + basePythonVersionExpr + "' }}",
@@ -333,7 +344,7 @@ function main(): void {
333344

334345
steps.push({
335346
name: "Install .NET",
336-
uses: "actions/setup-dotnet@v5",
347+
uses: getActionRef("actions/setup-dotnet"),
337348
with: {
338349
"dotnet-version":
339350
"${{ inputs.dotnet-version || '" + baseDotNetVersionExpr + "' }}",

0 commit comments

Comments
 (0)