-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(deploy): add an example of how to deploy homer
- Loading branch information
Showing
5 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Get the most recent base image with the correct architecture from https://github.com/ManoManoTech/homer/pkgs/container/homer | ||
FROM ghcr.io/manomanotech/homer:v0.3.0@sha256:ad5568ba02911beaf51633acd5bc63df8d815a07ea8953472ff9e4b7f1df4510 | ||
|
||
# Copy the configuration file and the plugins at the correct location | ||
COPY config/ dist/config/ | ||
COPY plugins/ dist/plugins/ | ||
|
||
CMD ["node", "dist/src/index.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Homer Deployment Example | ||
|
||
This is an example project of how to use the Homer open source [image](https://github.com/ManoManoTech/homer/pkgs/container/homer) to build and deploy your own version. |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"projects": [ | ||
{ | ||
"description": "project_example", | ||
"notificationChannelIds": ["C0XXXXXXXXX"], | ||
"projectId": 1234, | ||
"releaseChannelId": "C0XXXXXXXXX", | ||
"releaseManager": "myReleaseManager", | ||
"releaseTagManager": "stableDateReleaseTagManager" | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const jobsToCheckBeforeRelease = ['Build Image']; | ||
async function getReleaseStateUpdate( | ||
{ failedDeployments, state, successfulDeployments }, | ||
deploymentHook | ||
) { | ||
if (deploymentHook === undefined) { | ||
const isProductionEnvironment = successfulDeployments.some((env) => | ||
env.startsWith('production') | ||
); | ||
return isProductionEnvironment && state === 'monitoring' | ||
? [{ deploymentState: 'completed', environment: 'production' }] | ||
: []; | ||
} | ||
const { environment, status } = deploymentHook; | ||
if (environment.startsWith('staging')) { | ||
switch (status) { | ||
case 'failed': | ||
return [{ deploymentState: 'failed', environment: 'staging' }]; | ||
case 'running': | ||
return [{ deploymentState: 'deploying', environment: 'staging' }]; | ||
case 'success': | ||
return [{ deploymentState: 'monitoring', environment: 'staging' }]; | ||
default: | ||
throw new Error(`Unhandled staging deployment status: ${status}`); | ||
} | ||
} else if (environment.startsWith('production')) { | ||
switch (status) { | ||
case 'failed': | ||
return [{ deploymentState: 'failed', environment: 'production' }]; | ||
case 'running': | ||
return failedDeployments.length === 0 | ||
? [ | ||
{ deploymentState: 'completed', environment: 'staging' }, | ||
{ deploymentState: 'deploying', environment: 'production' }, | ||
] | ||
: [{ deploymentState: 'deploying', environment: 'production' }]; | ||
case 'success': | ||
return [{ deploymentState: 'monitoring', environment: 'production' }]; | ||
default: | ||
throw new Error(`Unhandled production deployment status: ${status}`); | ||
} | ||
} | ||
return []; | ||
} | ||
async function isReadyToRelease( | ||
{ projectId }, | ||
mainBranchPipelineId, | ||
{ gitlab: { fetchPipelineJobs } } | ||
) { | ||
const pipelinesJobs = await fetchPipelineJobs( | ||
projectId, | ||
mainBranchPipelineId | ||
); | ||
const buildJob = pipelinesJobs.find((job) => | ||
jobsToCheckBeforeRelease.includes(job.name) | ||
); | ||
return buildJob?.status === 'success'; | ||
} | ||
const myReleaseManager = { | ||
getReleaseStateUpdate, | ||
isReadyToRelease, | ||
}; | ||
exports.default = myReleaseManager; |