Skip to content

Commit

Permalink
fix(staging-deployment): fix invalid tag
Browse files Browse the repository at this point in the history
  • Loading branch information
hugotiburtino committed Dec 14, 2023
1 parent ac55e55 commit 658413f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions packages/server/scripts/deploy-staging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, '..')
Expand All @@ -14,32 +13,37 @@ 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',
})
}

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(
Expand Down

0 comments on commit 658413f

Please sign in to comment.