generated from DFE-Digital/govuk-dotnet-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added defensive environment variable checks where appropriate, remove…
…d some debugging
- Loading branch information
1 parent
e7b415e
commit b649708
Showing
5 changed files
with
65 additions
and
14 deletions.
There are no files selected for viewing
27 changes: 21 additions & 6 deletions
27
Contentful-Schema/utils/create-initial-migration-version.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
import contentful from 'contentful-management'; | ||
import chalk from 'chalk'; | ||
import core from '@actions/core'; | ||
|
||
console.log('space id: ', process.env.SPACE_ID); | ||
const red = chalk.bold.red; | ||
const managementToken = process.env.MANAGEMENT_TOKEN; | ||
const spaceId = process.env.SPACE_ID; | ||
const contentfulAlias = process.env.ENVIRONMENT; | ||
|
||
try { | ||
if (!managementToken) throw new Error("Environment variable MANAGEMENT_TOKEN not set"); | ||
if (!spaceId) throw new Error("Environment variable SPACE_ID not set"); | ||
if (!contentfulAlias) throw new Error("Environment variable ENVIRONMENT not set"); | ||
} | ||
catch (e) { | ||
core.setFailed(red(e)); | ||
process.exit(); | ||
} | ||
|
||
var client = contentful.createClient( | ||
{ accessToken: process.env.MANAGEMENT_TOKEN }, | ||
{ accessToken: managementToken }, | ||
{ type: 'plain' } | ||
); | ||
|
||
const newMigrationVersionEntry = await client.entry.create ({ | ||
environmentId: process.env.ENVIRONMENT, | ||
spaceId: process.env.SPACE_ID, | ||
environmentId: contentfulAlias, | ||
spaceId: spaceId, | ||
contentTypeId: 'migrationVersion' | ||
}, {}) | ||
|
||
await client.entry.publish({ | ||
environmentId: process.env.ENVIRONMENT, | ||
spaceId: process.env.SPACE_ID, | ||
environmentId: contentfulAlias, | ||
spaceId: spaceId, | ||
entryId: newMigrationVersionEntry.sys.id | ||
}, newMigrationVersionEntry); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters