mirror of
https://github.com/actions/configure-pages.git
synced 2025-12-08 08:06:09 +00:00
Use error-utils to add error metadata to Actions workflow run annotations
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const core = require('@actions/core')
|
||||
const github = require('@actions/github')
|
||||
const { convertErrorToAnnotationProperties } = require('./error-utils')
|
||||
|
||||
async function enablePagesSite({ githubToken }) {
|
||||
const octokit = github.getOctokit(githubToken)
|
||||
@@ -43,20 +44,25 @@ async function findOrCreatePagesSite({ githubToken, enablement = true }) {
|
||||
} catch (error) {
|
||||
if (!enablement) {
|
||||
core.error(
|
||||
'Get Pages site failed. Please verify that the repository has Pages enabled and configured to build using GitHub Actions, or consider exploring the `enablement` parameter for this action.',
|
||||
error
|
||||
`Get Pages site failed. Please verify that the repository has Pages enabled and configured to build using GitHub Actions, or consider exploring the \`enablement\` parameter for this action. Error: ${error.message}`,
|
||||
convertErrorToAnnotationProperties(error)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
core.warning('Get Pages site failed', error)
|
||||
}
|
||||
core.warning(
|
||||
`Get Pages site failed. Error: ${error.message}`,
|
||||
convertErrorToAnnotationProperties(error)
|
||||
)
|
||||
|
||||
if (!pageObject && enablement) {
|
||||
// Create a new Pages site if one doesn't exist
|
||||
try {
|
||||
pageObject = await enablePagesSite({ githubToken })
|
||||
} catch (error) {
|
||||
core.error('Create Pages site failed', error)
|
||||
core.error(
|
||||
`Create Pages site failed. Error: ${error.message}`,
|
||||
convertErrorToAnnotationProperties(error)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
|
||||
@@ -66,7 +72,10 @@ async function findOrCreatePagesSite({ githubToken, enablement = true }) {
|
||||
try {
|
||||
pageObject = await getPagesSite({ githubToken })
|
||||
} catch (error) {
|
||||
core.error('Get Pages site still failed', error)
|
||||
core.error(
|
||||
`Get Pages site still failed. Error: ${error.message}`,
|
||||
convertErrorToAnnotationProperties(error)
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const core = require('@actions/core')
|
||||
const { ConfigParser } = require('./config-parser')
|
||||
const removeTrailingSlash = require('./remove-trailing-slash')
|
||||
const { convertErrorToAnnotationProperties } = require('./error-utils')
|
||||
|
||||
const SUPPORTED_FILE_EXTENSIONS = ['.js', '.cjs', '.mjs']
|
||||
|
||||
@@ -88,13 +89,13 @@ function setPagesConfig({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
|
||||
core.warning(
|
||||
`Unsupported configuration file extension. Currently supported extensions: ${SUPPORTED_FILE_EXTENSIONS.map(
|
||||
ext => JSON.stringify(ext)
|
||||
).join(', ')}`,
|
||||
error
|
||||
).join(', ')}. Error: ${error.message}`,
|
||||
convertErrorToAnnotationProperties(error)
|
||||
)
|
||||
} else {
|
||||
core.warning(
|
||||
`We were unable to determine how to inject the site metadata into your config. Generated URLs may be incorrect. The base URL for this site should be ${siteUrl}. Please ensure your framework is configured to generate relative links appropriately.`,
|
||||
error
|
||||
`We were unable to determine how to inject the site metadata into your config. Generated URLs may be incorrect. The base URL for this site should be ${siteUrl}. Please ensure your framework is configured to generate relative links appropriately. Error: ${error.message}`,
|
||||
convertErrorToAnnotationProperties(error)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user