Skip to content

Commit

Permalink
feat(deploy): setup workaround for outdated tags in latest major (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
kon14 authored Jul 25, 2022
1 parent 28d17d1 commit 59355b6
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/commands/deploy/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class DeploySetup extends Command {
private readonly deployConfigBasePath = path.join(this.config.configDir, 'deploy');
private userConfiguration!: boolean;
private conduitTags: string[] = [];
private conduitUiTags: string[] = [];
private selectedTag!: string;
private deploymentConfig: DeploymentConfiguration = {
modules: [],
Expand All @@ -32,7 +33,8 @@ export class DeploySetup extends Command {

async run() {
// Get Conduit Releases
await this.getTags();
await this.getTags('Conduit');
await this.getTags('Conduit-UI');
this.userConfiguration = (await this.parse(DeploySetup)).flags.config;
// Select Target Release
if (!this.userConfiguration) {
Expand Down Expand Up @@ -108,9 +110,9 @@ export class DeploySetup extends Command {
.catch(() => CliUx.ux.error('Failed to download env file', { exit: -1 }));
}

private async getTags() {
private async getTags(repo: 'Conduit' | 'Conduit-UI') {
const res = await axios.get(
'https://api.github.com/repos/ConduitPlatform/Conduit/releases',
`https://api.github.com/repos/ConduitPlatform/${repo}/releases`,
{ headers: { Accept: 'application/vnd.github.v3+json' } },
);
const releases: string[] = [];
Expand All @@ -125,7 +127,11 @@ export class DeploySetup extends Command {
releases.sort().reverse();
rcReleases.sort().reverse();
releases.push(...rcReleases);
this.conduitTags = releases;
if (repo === 'Conduit') {
this.conduitTags = releases;
} else {
this.conduitUiTags = releases;
}
}

private async indexSupportedModules() {
Expand Down Expand Up @@ -166,6 +172,15 @@ export class DeploySetup extends Command {
}

private async configureEnvironment() {
// If selected tag's major is the latest major, explicitly specify target Conduit tag and latest Conduit-UI.
// This is a workaround for outdated env files in the main branch.
const tagPrefix = this.selectedTag.slice(1).split('.').slice(0, 2).join('.');
if (this.conduitTags[0].startsWith(`v${tagPrefix}`)) {
this.deploymentConfig.environment = {
IMAGE_TAG: this.selectedTag,
UI_IMAGE_TAG: this.conduitUiTags[0],
};
}
// TODO: Parse .env file and prompt for overrides
if (this.deploymentConfig.modules.includes('postgres')) {
this.deploymentConfig.environment.DB_CONN_URI =
Expand Down

0 comments on commit 59355b6

Please sign in to comment.