-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Uroš Marolt
committed
Jan 9, 2024
1 parent
ca768fb
commit 540e984
Showing
7 changed files
with
1,492 additions
and
23 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { getInputs } from './inputs' | ||
import { setImageTag } from './state' | ||
import { ActionStep } from './types' | ||
import * as core from '@actions/core' | ||
import * as exec from '@actions/exec' | ||
|
||
export const buildStep = async (): Promise<void> => { | ||
const inputs = await getInputs() | ||
|
||
if (inputs[ActionStep.BUILD] === undefined) { | ||
core.error('No build inputs provided!') | ||
throw new Error('No build inputs provided!') | ||
} | ||
|
||
const { images, tag } = inputs[ActionStep.BUILD] | ||
if (images.length === 0) { | ||
core.error('No images provided!') | ||
throw new Error('No images provided!') | ||
} | ||
|
||
if (!tag) { | ||
core.error('No tag provided!') | ||
throw new Error('No tag provided!') | ||
} | ||
|
||
const timestamp = Math.floor(Date.now() / 1000) | ||
|
||
const actualTag = `${tag}.${timestamp}` | ||
|
||
for (const image of images) { | ||
core.info(`Building image: ${image}:${actualTag}`) | ||
const exitCode = await exec.exec('bash', ['./scripts/cli', 'build', image, tag], { | ||
listeners: { | ||
stdout: (data) => { | ||
core.info(`${image} builder: ${data.toString()}`) | ||
}, | ||
stderr: (data) => { | ||
core.error(`${image} builder error: ${data.toString()}`) | ||
}, | ||
}, | ||
}) | ||
|
||
if (exitCode !== 0) { | ||
core.error(`Failed to build image: ${image}:${actualTag}`) | ||
throw new Error(`Failed to build image: ${image}:${actualTag}`) | ||
} | ||
|
||
setImageTag(image, actualTag) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters