Skip to content

Commit c6f8c3d

Browse files
ci(action): update actions/checkout digest to 8ade135 (#67)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent 138d685 commit c6f8c3d

File tree

6 files changed

+86
-8
lines changed

6 files changed

+86
-8
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
41+
uses: actions/checkout@v4
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: release
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
14+
- uses: actions/checkout@v4
1515
- uses: actions/setup-node@v3
1616
with:
1717
node-version: "lts/*"

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
17-
- uses: actions/setup-node@v3 # tag=v3
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v3
1818
with:
1919
node-version: "lts/*"
2020
cache: npm

.github/workflows/update.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
# These steps should be kept in sync with `update_dry_run.yml` - minus the code that
1212
# actually commits, pushes and creates a PR.
1313
steps:
14-
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
15-
- uses: actions/setup-node@v3 # tag=v3
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v3
1616
with:
1717
cache: npm
1818
node-version: 18

.github/workflows/update_dry_run.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
# These steps should be kept in sync with `update.yml` - minus the code that actually
1313
# commits, pushes and creates a PR.
1414
steps:
15-
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
16-
- uses: actions/setup-node@v3 # tag=v3
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-node@v3
1717
with:
1818
cache: npm
1919
node-version: 18

scripts/overrides/index.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { readFileSync } from "fs";
2+
import { resolve, join, dirname } from "path";
3+
import { fileURLToPath } from "url";
4+
5+
const SUPPORTED_GHES_OPERATIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"];
6+
const __dirname = dirname(fileURLToPath(import.meta.url));
7+
8+
function isDeferenced(filename) {
9+
return /deref/.test(filename);
10+
}
11+
12+
// Updates the operation ID for a specific operation. Useful if you want to maintain
13+
// the function name in `plugin-rest-endpoint-methods.js` when the operation ID has
14+
// been changed in the OpenAPI specification.
15+
//
16+
// Throws an error if an operation is not found for the specified path and HTTP method.
17+
function rewriteOperationId(schema, path, httpMethod, operationId) {
18+
if (!schema.paths[path]) {
19+
throw `Path ${path} found not found in schema`;
20+
}
21+
22+
if (!schema.paths[path][httpMethod]) {
23+
throw `HTTP method ${httpMethod} not found for path ${path} in schema`;
24+
}
25+
26+
schema.paths[path][httpMethod].operationId = operationId;
27+
}
28+
29+
// Adds an operation to the OpenAPI specification using JSON data stored in a file.
30+
//
31+
// Throws an error if an operation already exists for the specified path and HTTP method.
32+
function addOperation(schema, path, httpMethod, overridePath) {
33+
if (schema.paths[path] && schema.paths[path][httpMethod]) {
34+
throw `Operation \`${httpMethod} ${path}\` already exists`;
35+
}
36+
37+
if (!schema.paths[path]) {
38+
schema.paths[path] = {};
39+
}
40+
41+
schema.paths[path][httpMethod] = JSON.parse(
42+
readFileSync(resolve(join(__dirname, overridePath)), "utf8"),
43+
);
44+
}
45+
46+
// Replaces a given operation using JSON data stored in a file.
47+
//
48+
// Throws an error if an operation is not found for the specified path and HTTP method.
49+
function replaceOperation(schema, path, httpMethod, overridePath) {
50+
if (!schema.paths[path]) {
51+
throw `Path ${path} not found in schema`;
52+
}
53+
54+
if (!schema.paths[path][httpMethod]) {
55+
throw `HTTP method ${httpMethod} not found for path ${path} in schema`;
56+
}
57+
58+
schema.paths[path][httpMethod] = JSON.parse(
59+
readFileSync(resolve(join(__dirname, overridePath)), "utf8"),
60+
);
61+
}
62+
63+
export default function overrides(file, schema) {
64+
const isGHES = file.startsWith("ghes-");
65+
const isAE = file.startsWith("github.ae");
66+
const isDotcom = file.startsWith("api.github.com");
67+
const ghesVersion = isGHES ? file.match(/(?<=^ghes-)\d+\.\d+/)[0] : null;
68+
69+
if (isGHES && SUPPORTED_GHES_OPERATIONS.indexOf(ghesVersion) == -1) {
70+
throw (
71+
`GHES version ${ghesVersion} is not yet supported. Please check the overrides ` +
72+
`in \`scripts/overrides/index.js\` to check if they are relevant to this version, ` +
73+
`and then update \`SUPPORTED_GHES_VERSION\`.`
74+
);
75+
}
76+
77+
78+
}

0 commit comments

Comments
 (0)