Skip to content

Commit

Permalink
fix: handle branches with / in name
Browse files Browse the repository at this point in the history
  • Loading branch information
maxpatiiuk committed Jan 23, 2024
1 parent b5d6934 commit dd5fcd7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/lib/dockerCompose.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import type { ActiveDeployment, Deployment } from './deployment';
import type { RA } from './typescriptCommonTypes';

// As per https://github.com/specify/specify7/blob/e52a2c09d41aa65f623f2bd73126dd594f5d9522/.github/workflows/docker.yml#L30
export const branchToTag = (branch: string) => branch.replaceAll('/', '-');
export const tagToBranch = (branch: string) => branch.replaceAll('-', '/');

const resolveVersion = (deployment: Deployment) =>
typeof deployment.digest === 'string'
? `@${deployment.digest}`
: `:${deployment.branch}`;
: `:${branchToTag(deployment.branch)}`;

export const createDockerConfig = (
deployments: RA<ActiveDeployment>,
Expand Down
3 changes: 2 additions & 1 deletion app/pages/api/dockerhub/[image].ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { NextApiRequest, NextApiResponse } from 'next';

import type { IR, RA } from '../../../lib/typescriptCommonTypes';
import { tagToBranch } from '../../../lib/dockerCompose';

export type DockerHubTag = {
readonly lastUpdated: string;
Expand Down Expand Up @@ -36,7 +37,7 @@ const processTagsResponse = (tags: Response['results']): IR<DockerHubTag> =>
tags
.filter(({ name }) => !name.startsWith('sha-'))
.map(({ name, last_updated, digest }) => [
name,
tagToBranch(name),
{
lastUpdated: last_updated,
digest,
Expand Down

0 comments on commit dd5fcd7

Please sign in to comment.