From 658413f69080fa1b0677d75a70b19527c853b6e9 Mon Sep 17 00:00:00 2001 From: Hugo Tiburtino Date: Thu, 14 Dec 2023 11:18:15 +0100 Subject: [PATCH] fix(staging-deployment): fix invalid tag --- packages/server/scripts/deploy-staging.ts | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/server/scripts/deploy-staging.ts b/packages/server/scripts/deploy-staging.ts index 020c81145..7bccbdb8a 100644 --- a/packages/server/scripts/deploy-staging.ts +++ b/packages/server/scripts/deploy-staging.ts @@ -2,7 +2,6 @@ import { spawnSync } from 'node:child_process' import * as path from 'node:path' import { fileURLToPath } from 'node:url' - const __dirname = path.dirname(fileURLToPath(import.meta.url)) const root = path.join(__dirname, '..') @@ -14,13 +13,13 @@ function run() { name: 'api-server', Dockerfile: path.join(root, 'docker', 'server', 'Dockerfile'), context: '../..', - envName: 'staging' + envName: 'staging', }) buildDockerImage({ name: 'api-swr-queue-worker', Dockerfile: path.join(root, 'docker', 'swr-queue-worker', 'Dockerfile'), context: '../..', - envName: 'staging' + envName: 'staging', }) } @@ -28,18 +27,23 @@ function buildDockerImage({ name, Dockerfile, context, - envName + envName, }: DockerImageOptions) { const remoteName = `eu.gcr.io/serlo-shared/${name}` - const date = new Date + const date = new Date() const timestamp = `${date.toISOString().split('T')[0]}-${date.getTime()}` - const {stdout: gitHash} = spawnSync( - 'git', - ['rev-parse', '--short', 'HEAD'], - ) + const { stdout: gitHashBuffer } = spawnSync('git', [ + 'rev-parse', + '--short', + 'HEAD', + ]) - const remoteTags = toTags(remoteName, [envName, timestamp, gitHash.toString()]) + const remoteTags = toTags(remoteName, [ + envName, + timestamp, + gitHashBuffer.toString().split('\n')[0], + ]) const tags = [...remoteTags, ...toTags(name, [envName])] spawnSync(