Skip to content

Commit

Permalink
fix: Added release notes file back in, as trying to pass large data t…
Browse files Browse the repository at this point in the history
…hrough action outputs isn't practical (#367)
  • Loading branch information
slewis74 committed Dec 23, 2022
1 parent 58a66b1 commit f4b624a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,21 @@ steps:

## 📥 Inputs

| Name | Description |
| :---------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `project` | **Required.** The name of the project associated with this release. |
| `release_number` | The number for the new release. If omitted, Octopus Deploy will generate a release number. |
| `channel` | The name of the channel to use for the new release. If omitted, the best channel will be selected. |
| `package_version` | The version number of all packages to use for this release. |
| `packages` | A multi-line list of version numbers to use for a package in the release. Format: StepName:Version or PackageID:Version or StepName:PackageName:Version. StepName, PackageID, and PackageName can be replaced with an asterisk ("\*"). An asterisk will be assumed for StepName, PackageID, or PackageName if they are omitted. |
| `git_ref` | Git branch reference to the specific resources of a version controlled Octopus Project. This is required for version controlled projects. E.g. `${{ github.ref }}` to use the branch or tag ref that triggered the workflow. |
| `git_commit` | Git commit pointing to the specific resources of a version controlled Octopus Project. If empty, it will use the HEAD from the corresponding gitRef parameter. E.g. `${{ github.sha }}` to use the commit SHA that triggered the workflow. |
| `ignore_existing` | Ignore existing releases if present in Octopus Deploy with the matching version number. Defaults to **false** |
| `release_notes` | The release notes associated with the new release (Markdown is supported). |
| `server` | The instance URL hosting Octopus Deploy (i.e. "https://octopus.example.com/"). The instance URL is required, but you may also use the OCTOPUS_URL environment variable. |
| `api_key` | The API key used to access Octopus Deploy. An API key is required, but you may also use the OCTOPUS_API_KEY environment variable. It is strongly recommended that this value retrieved from a GitHub secret. |
| `space` | The name of a space within which this command will be executed. The space name is required, but you may also use the OCTOPUS_SPACE environment variable. |
| Name | Description |
| :------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `project` | **Required.** The name of the project associated with this release. |
| `release_number` | The number for the new release. If omitted, Octopus Deploy will generate a release number. |
| `channel` | The name of the channel to use for the new release. If omitted, the best channel will be selected. |
| `package_version` | The version number of all packages to use for this release. |
| `packages` | A multi-line list of version numbers to use for a package in the release. Format: StepName:Version or PackageID:Version or StepName:PackageName:Version. StepName, PackageID, and PackageName can be replaced with an asterisk ("\*"). An asterisk will be assumed for StepName, PackageID, or PackageName if they are omitted. |
| `git_ref` | Git branch reference to the specific resources of a version controlled Octopus Project. This is required for version controlled projects. E.g. `${{ github.ref }}` to use the branch or tag ref that triggered the workflow. |
| `git_commit` | Git commit pointing to the specific resources of a version controlled Octopus Project. If empty, it will use the HEAD from the corresponding gitRef parameter. E.g. `${{ github.sha }}` to use the commit SHA that triggered the workflow. |
| `ignore_existing` | Ignore existing releases if present in Octopus Deploy with the matching version number. Defaults to **false** |
| `release_notes` | The release notes text associated with the new release (Markdown is supported). |
| `release_notes_file` | A file containing the release notes associated with the new release (Markdown is supported). Use either `release_notes` or this input, supplying both is not supported. |
| `server` | The instance URL hosting Octopus Deploy (i.e. "https://octopus.example.com/"). The instance URL is required, but you may also use the OCTOPUS_URL environment variable. |
| `api_key` | The API key used to access Octopus Deploy. An API key is required, but you may also use the OCTOPUS_API_KEY environment variable. It is strongly recommended that this value retrieved from a GitHub secret. |
| `space` | The name of a space within which this command will be executed. The space name is required, but you may also use the OCTOPUS_SPACE environment variable. |

## 📤 Outputs

Expand Down
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ inputs:
default: false
description: 'Ignore existing releases if present in Octopus Deploy with the matching version number.'
release_notes:
description: 'The release notes associated with the new release (Markdown is supported).'
description: 'The release notes text associated with the new release (Markdown is supported).'
release_notes_file:
description: 'A file containing the release notes associated with the new release (Markdown is supported). Use either `release_notes` or this input, supplying both is not supported.'
server:
description: 'The instance URL hosting Octopus Deploy (i.e. "https://octopus.example.com/"). The instance URL is required, but you may also use the OCTOPUS_URL environment variable.'
api_key:
Expand Down
9 changes: 8 additions & 1 deletion src/api-wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { InputParameters } from './input-parameters'
import { Client, CreateReleaseCommandV1, ReleaseRepository } from '@octopusdeploy/api-client'
import fs from 'fs'

export async function createReleaseFromInputs(client: Client, parameters: InputParameters): Promise<string> {
client.info('🐙 Creating a release in Octopus Deploy...')

let releaseNotes = parameters.releaseNotes
if (parameters.releaseNotesFile) {
const data = fs.readFileSync(parameters.releaseNotesFile)
releaseNotes = data.toString()
}

const command: CreateReleaseCommandV1 = {
spaceName: parameters.space,
ProjectName: parameters.project,
Expand All @@ -13,7 +20,7 @@ export async function createReleaseFromInputs(client: Client, parameters: InputP
Packages: parameters.packages,
GitRef: parameters.gitRef,
GitCommit: parameters.gitCommit,
ReleaseNotes: parameters.releaseNotes,
ReleaseNotes: releaseNotes,
IgnoreIfAlreadyExists: parameters.ignoreExisting,
IgnoreChannelRules: false
}
Expand Down
9 changes: 8 additions & 1 deletion src/input-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface InputParameters {

// Optional
releaseNotes?: string
releaseNotesFile?: string
}

export function getInputParameters(): InputParameters {
Expand All @@ -40,7 +41,8 @@ export function getInputParameters(): InputParameters {
gitRef: getInput('git_ref') || undefined,
gitCommit: getInput('git_commit') || undefined,
ignoreExisting: getBooleanInput('ignore_existing') || undefined,
releaseNotes: getInput('release_notes') || undefined
releaseNotes: getInput('release_notes') || undefined,
releaseNotesFile: getInput('release_notes_file') || undefined
}

const errors: string[] = []
Expand All @@ -59,6 +61,11 @@ export function getInputParameters(): InputParameters {
"The Octopus space name is required, please specify explictly through the 'space' input or set the OCTOPUS_SPACE environment variable."
)
}
if (parameters.releaseNotes && parameters.releaseNotesFile) {
errors.push(
'Please specify one or other of `release_notes` and `release_notes_files`. Specifying both is not supported.'
)
}

if (errors.length > 0) {
throw new Error(errors.join('\n'))
Expand Down

0 comments on commit f4b624a

Please sign in to comment.