diff --git a/src/main.ts b/src/main.ts index 1735fae..6a8cd8f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -85,16 +85,21 @@ async function run(): Promise { return; } - // Add repo tag for this version at the current commit. + // Add repo tag for newly published Feature(s) at the current commit. if (!disableRepoTagging) { - for (const featureId in publishedFeatures) { - const version = publishedFeatures[featureId]?.version; - if (!version) { - core.debug(`No version available for '${featureId}', so no repo tag was added for Feature`); - continue; - } - if (!(await addRepoTagForPublishedTag('feature', featureId, version))) { - continue; + const authToken = process.env.GITHUB_TOKEN; + if (!authToken) { + core.warning(`Repo tagging will be skipped because a 'GITHUB_TOKEN' is not set on this action.`); + } else { + // Add the repo tags + for (const featureId in publishedFeatures) { + const version = publishedFeatures[featureId]?.version; + if (!version) { + core.debug(`No version available for '${featureId}', so no repo tag was added for Feature`); + continue; + } + + await addRepoTagForPublishedTag('feature', featureId, version, authToken); } } } @@ -108,16 +113,21 @@ async function run(): Promise { return; } - // Add repo tag for this version at the current commit. + // Add repo tag for newly published Template(s) at the current commit. if (!disableRepoTagging) { - for (const templateId in publishedTemplates) { - const version = publishedTemplates[templateId]?.version; - if (!version) { - core.debug(`No version available for '${templateId}', so no repo tag was added for Feature`); - continue; - } - if (!(await addRepoTagForPublishedTag('template', templateId, version))) { - continue; + const authToken = process.env.GITHUB_TOKEN; + if (!authToken) { + core.warning(`Repo tagging will be skipped because a 'GITHUB_TOKEN' is not set on this action.`); + } else { + // Add the repo tags + for (const templateId in publishedTemplates) { + const version = publishedTemplates[templateId]?.version; + if (!version) { + core.debug(`No version available for '${templateId}', so no repo tag was added for Feature`); + continue; + } + + await addRepoTagForPublishedTag('template', templateId, version, authToken); } } } diff --git a/src/schemas/devContainerFeature.schema.json b/src/schemas/devContainerFeature.schema.json index ce8ed87..4724161 100644 --- a/src/schemas/devContainerFeature.schema.json +++ b/src/schemas/devContainerFeature.schema.json @@ -102,6 +102,106 @@ "deprecated": { "description": "Indicates that the Feature is deprecated, and will not receive any further updates/support. This property is intended to be used by the supporting tools for highlighting Feature deprecation.", "type": "boolean" + }, + "onCreateCommand": { + "type": [ + "string", + "array", + "object" + ], + "description": "A command to run when creating the container. This command is run after \"initializeCommand\" and before \"updateContentCommand\". If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell. If this is an object, each provided command will be run in parallel.", + "items": { + "type": "string" + }, + "additionalProperties": { + "type": [ + "string", + "array" + ], + "items": { + "type": "string" + } + } + }, + "updateContentCommand": { + "type": [ + "string", + "array", + "object" + ], + "description": "A command to run when creating the container and rerun when the workspace content was updated while creating the container. This command is run after \"onCreateCommand\" and before \"postCreateCommand\". If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell. If this is an object, each provided command will be run in parallel.", + "items": { + "type": "string" + }, + "additionalProperties": { + "type": [ + "string", + "array" + ], + "items": { + "type": "string" + } + } + }, + "postCreateCommand": { + "type": [ + "string", + "array", + "object" + ], + "description": "A command to run after creating the container. This command is run after \"updateContentCommand\" and before \"postStartCommand\". If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell. If this is an object, each provided command will be run in parallel.", + "items": { + "type": "string" + }, + "additionalProperties": { + "type": [ + "string", + "array" + ], + "items": { + "type": "string" + } + } + }, + "postStartCommand": { + "type": [ + "string", + "array", + "object" + ], + "description": "A command to run after starting the container. This command is run after \"postCreateCommand\" and before \"postAttachCommand\". If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell. If this is an object, each provided command will be run in parallel.", + "items": { + "type": "string" + }, + "additionalProperties": { + "type": [ + "string", + "array" + ], + "items": { + "type": "string" + } + } + }, + "postAttachCommand": { + "type": [ + "string", + "array", + "object" + ], + "description": "A command to run when attaching to the container. This command is run after \"postStartCommand\". If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell. If this is an object, each provided command will be run in parallel.", + "items": { + "type": "string" + }, + "additionalProperties": { + "type": [ + "string", + "array" + ], + "items": { + "type": "string" + } + } } }, "required": [ @@ -234,4 +334,4 @@ "$ref": "#/definitions/Feature" } ] -} +} \ No newline at end of file diff --git a/src/utils.ts b/src/utils.ts index 4bdd346..4e1a8a9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -53,8 +53,8 @@ export async function isDevcontainerCliAvailable(cliDebugMode = false): Promise< } } -export async function addRepoTagForPublishedTag(type: string, id: string, version: string): Promise { - const octokit = github.getOctokit(process.env.GITHUB_TOKEN || ''); +export async function addRepoTagForPublishedTag(type: string, id: string, version: string, authToken: string): Promise { + const octokit = github.getOctokit(authToken); const tag = `${type}_${id}_${version}`; core.info(`Adding repo tag '${tag}'...`); @@ -77,11 +77,9 @@ export async function addRepoTagForPublishedTag(type: string, id: string, versio } catch (err) { core.warning(`Failed to automatically add repo tag, manually tag with: 'git tag ${tag} ${github.context.sha}'`); core.debug(`${err}`); - return false; } core.info(`Tag '${tag}' added.`); - return true; } export async function ensureDevcontainerCliPresent(cliDebugMode = false): Promise {