Skip to content

Commit

Permalink
docs(deploy): add an example of how to deploy homer
Browse files Browse the repository at this point in the history
  • Loading branch information
pfongkye committed Nov 7, 2024
1 parent 56b0f4b commit 4a9d057
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ If you want to get an overview of merge requests that are still being reviewed

## Install

> [!WARNING]
> Currently, Homer can only be installed by manually cloning the git repository.
> [!NOTE]
> Homer can be installed by either manually cloning the git repository or by using the package provided.
> Check the [deploy example](./examples/deploy/) to see how to deploy using the package.
### 1. Create the Slack app

Expand Down Expand Up @@ -330,6 +331,10 @@ Here is a sample configuration with one project:

A simple plugin system enables the addition of custom release managers. See this dedicated [page](./PLUGIN_RELEASE.md) for more details.

### 9. Examples

You can find some [examples](./examples/) to add your own configuration, plugins and how to deploy.

## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md).
8 changes: 8 additions & 0 deletions examples/deploy/Dockerfile
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"]
3 changes: 3 additions & 0 deletions examples/deploy/README.md
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.
12 changes: 12 additions & 0 deletions examples/deploy/config/homer/projects.json
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"
}
]
}
64 changes: 64 additions & 0 deletions examples/deploy/pugins/release/myReleaseManager.js
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;

0 comments on commit 4a9d057

Please sign in to comment.