Skip to content

Commit

Permalink
Добавил built-images output
Browse files Browse the repository at this point in the history
  • Loading branch information
identw committed Dec 8, 2023
1 parent 2b6d935 commit 6a3fe53
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,29 @@ registry, указывать без протокола (например `exampl

Список запушенных в registry образов в JSON формате: `["example.com/registry/image1:tag", "example.com/registry/image2:tag", ...]`

### `built-images`

Собранные образы в JSON формате: `{"image1": "example.com/registry/image1:tag", "image2": "example.com/registry/image2:tag", ...}`
Это удобно использовать если далее в пайплайне потребуется запустить контейнер из собранного образа
```yaml
- uses: orangeappsru/build-images-action@main
id: build-images
with:
registry: ${{ vars.REGISTRY }}
registry-user: ${{ secrets.REGISTRY_USER }}
registry-password: ${{ secrets.REGISTRY_PASSWORD }}
tag: latest
operation: build
build-opts: |
- name: native-builder
- name: test
env:
IMAGE: ${{ fromJson(steps.build-images.outputs.built-images)["native-builder"] }}
run: |
docker run --rm -v $(pwd):/app --workdir /app ${IMAGE} ./build.sh
```


### `build-opts`

Проброс в outputs того же самого что пришло в одноименную опцию в inputs
4 changes: 4 additions & 0 deletions js-action/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ async function main() {
// Build images
if (operation == 'build' || operation == 'build-and-push') {
let copyFiles = [];
let images = {};
createDir('copy-files');

for (const image of buildOpts) {

const imageTag = `${registry}/${repoName}/${image.name}:${tag}`;
console.log(`Build image: ${imageTag}`);
images[image] = imageTag;

let args = '';
if ('args' in image) {
Expand All @@ -56,6 +58,7 @@ async function main() {

// build image
runCommand(`docker build ${file} ${args} --tag ${imageTag} ${target} .`);


// Copy files
if ('copy-files' in image) {
Expand All @@ -73,6 +76,7 @@ async function main() {
}
}

core.setOutput('built-images', JSON.stringify(images));
core.setOutput('copy-files', JSON.stringify(copyFiles));
}

Expand Down

0 comments on commit 6a3fe53

Please sign in to comment.