mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-10-21 16:58:56 +08:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
982da8e78c | ||
|
a0fc8606d2 | ||
|
a1980784de | ||
|
f95e9c7459 |
@@ -547,9 +547,9 @@ You enable GitHub Dependency Graph support by setting the `dependency-graph` act
|
||||
| `generate-and-submit` | As per `generate`, but any generated dependency graph snapshots will be submitted at the end of the job. |
|
||||
| `download-and-submit` | Download any previously saved dependency graph snapshots, submitting them via the Dependency Submission API. This can be useful to collect all snapshots in a matrix of builds and submit them in one step. |
|
||||
|
||||
Example of a simple workflow that generates and submits a dependency graph:
|
||||
Example of a CI workflow that generates and submits a dependency graph:
|
||||
```yaml
|
||||
name: Submit dependency graph
|
||||
name: CI build
|
||||
on:
|
||||
push:
|
||||
|
||||
@@ -565,11 +565,12 @@ jobs:
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
dependency-graph: generate-and-submit
|
||||
- name: Run a build and generate the dependency graph which will be submitted post-job
|
||||
- name: Run the usual CI build (dependency-graph will be generated and submitted post-job)
|
||||
run: ./gradlew build
|
||||
```
|
||||
|
||||
The `contents: write` permission is not required to generate the dependency graph, but is required in order to submit the graph via the GitHub API. This permission will need to be explicitly enabled in the workflow file for dependency graph submission to succeed.
|
||||
The `contents: write` permission is required in order to submit (but not generate) the dependency graph file.
|
||||
Depending on [repository settings](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token), this permission may be available by default or may need to be explicitly enabled in the workflow file (as above).
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The above configuration will work for workflows that run as a result of commits to a repository branch,
|
||||
|
16
dist/main/index.js
vendored
16
dist/main/index.js
vendored
@@ -93696,10 +93696,7 @@ function submitDependencyGraphs(dependencyGraphFiles) {
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof request_error_1.RequestError) {
|
||||
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile);
|
||||
core.warning(`Failed to submit dependency graph ${relativeJsonFile}.\n` +
|
||||
"Please ensure that the 'contents: write' permission is available for the workflow job.\n" +
|
||||
"Note that this permission is never available for a 'pull_request' trigger from a repository fork.");
|
||||
core.warning(buildWarningMessage(jsonFile, error));
|
||||
}
|
||||
else {
|
||||
throw error;
|
||||
@@ -93708,6 +93705,17 @@ function submitDependencyGraphs(dependencyGraphFiles) {
|
||||
}
|
||||
});
|
||||
}
|
||||
function buildWarningMessage(jsonFile, error) {
|
||||
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile);
|
||||
const mainWarning = `Failed to submit dependency graph ${relativeJsonFile}.\n${String(error)}`;
|
||||
if (error.message === 'Resource not accessible by integration') {
|
||||
return `${mainWarning}
|
||||
Please ensure that the 'contents: write' permission is available for the workflow job.
|
||||
Note that this permission is never available for a 'pull_request' trigger from a repository fork.
|
||||
`;
|
||||
}
|
||||
return mainWarning;
|
||||
}
|
||||
function submitDependencyGraphFile(jsonFile) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const octokit = getOctokit();
|
||||
|
2
dist/main/index.js.map
vendored
2
dist/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
16
dist/post/index.js
vendored
16
dist/post/index.js
vendored
@@ -93696,10 +93696,7 @@ function submitDependencyGraphs(dependencyGraphFiles) {
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof request_error_1.RequestError) {
|
||||
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile);
|
||||
core.warning(`Failed to submit dependency graph ${relativeJsonFile}.\n` +
|
||||
"Please ensure that the 'contents: write' permission is available for the workflow job.\n" +
|
||||
"Note that this permission is never available for a 'pull_request' trigger from a repository fork.");
|
||||
core.warning(buildWarningMessage(jsonFile, error));
|
||||
}
|
||||
else {
|
||||
throw error;
|
||||
@@ -93708,6 +93705,17 @@ function submitDependencyGraphs(dependencyGraphFiles) {
|
||||
}
|
||||
});
|
||||
}
|
||||
function buildWarningMessage(jsonFile, error) {
|
||||
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile);
|
||||
const mainWarning = `Failed to submit dependency graph ${relativeJsonFile}.\n${String(error)}`;
|
||||
if (error.message === 'Resource not accessible by integration') {
|
||||
return `${mainWarning}
|
||||
Please ensure that the 'contents: write' permission is available for the workflow job.
|
||||
Note that this permission is never available for a 'pull_request' trigger from a repository fork.
|
||||
`;
|
||||
}
|
||||
return mainWarning;
|
||||
}
|
||||
function submitDependencyGraphFile(jsonFile) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const octokit = getOctokit();
|
||||
|
2
dist/post/index.js.map
vendored
2
dist/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -78,12 +78,7 @@ async function submitDependencyGraphs(dependencyGraphFiles: string[]): Promise<v
|
||||
await submitDependencyGraphFile(jsonFile)
|
||||
} catch (error) {
|
||||
if (error instanceof RequestError) {
|
||||
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile)
|
||||
core.warning(
|
||||
`Failed to submit dependency graph ${relativeJsonFile}.\n` +
|
||||
"Please ensure that the 'contents: write' permission is available for the workflow job.\n" +
|
||||
"Note that this permission is never available for a 'pull_request' trigger from a repository fork."
|
||||
)
|
||||
core.warning(buildWarningMessage(jsonFile, error))
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
@@ -91,6 +86,18 @@ async function submitDependencyGraphs(dependencyGraphFiles: string[]): Promise<v
|
||||
}
|
||||
}
|
||||
|
||||
function buildWarningMessage(jsonFile: string, error: RequestError): string {
|
||||
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile)
|
||||
const mainWarning = `Failed to submit dependency graph ${relativeJsonFile}.\n${String(error)}`
|
||||
if (error.message === 'Resource not accessible by integration') {
|
||||
return `${mainWarning}
|
||||
Please ensure that the 'contents: write' permission is available for the workflow job.
|
||||
Note that this permission is never available for a 'pull_request' trigger from a repository fork.
|
||||
`
|
||||
}
|
||||
return mainWarning
|
||||
}
|
||||
|
||||
async function submitDependencyGraphFile(jsonFile: string): Promise<void> {
|
||||
const octokit = getOctokit()
|
||||
const jsonContent = fs.readFileSync(jsonFile, 'utf8')
|
||||
|
@@ -168,7 +168,7 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
|
||||
}
|
||||
}
|
||||
|
||||
void applyPluginExternally(PluginManager pluginManager, String pluginClassName) {
|
||||
void applyPluginExternally(def pluginManager, String pluginClassName) {
|
||||
def externallyApplied = 'gradle.enterprise.externally-applied'
|
||||
def oldValue = System.getProperty(externallyApplied)
|
||||
System.setProperty(externallyApplied, 'true')
|
||||
|
Reference in New Issue
Block a user