Skip to content

Commit

Permalink
fix(docker): Make container independent from build output
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanChepurnyi committed Jan 3, 2025
1 parent 2f24d7a commit aadfed7
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 41 deletions.
4 changes: 0 additions & 4 deletions .github/actions/build-magento/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ inputs:
required: false
description: COMPOSER_AUTH value
default: "{}"
containers:
required: false
description: JSON with containers that are going to be generated
default: "[]"
stability:
required: false
description: Preferred stability for composer packages
Expand Down
3 changes: 0 additions & 3 deletions .github/actions/build-magento/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116623,9 +116623,6 @@ async function run(actionPath) {
artifactDir,
);
});

(0,core.setOutput)("containers", (0,core.getInput)("containers"));
(0,core.setOutput)("artifact", (0,core.getInput)("artifact"));
} catch (e) {
(0,core.error)(`Failed to install Magento: ${e}`);
throw e;
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/build-magento/dist/index.js.map

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions .github/actions/build-magento/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ export async function run(actionPath) {
artifactDir,
);
});

setOutput("containers", getInput("containers"));
setOutput("artifact", getInput("artifact"));
} catch (e) {
error(`Failed to install Magento: ${e}`);
throw e;
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/generate-matrix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ inputs:
outputs:
magento:
description: JSON with versions of Magento to build with all variations
containers:
description: JSON with container build specification based on Magento artifacts
runs:
using: node20
main: dist/index.js
29 changes: 18 additions & 11 deletions .github/actions/generate-matrix/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28257,6 +28257,7 @@ var semver_default = /*#__PURE__*/__nccwpck_require__.n(semver);

async function run() {
const magento = [];
const containers = [];
const requestedVersion = (0,core.getInput)("version");
const requestedVariation = (0,core.getInput)("variation");
for (const variation of variations) {
Expand Down Expand Up @@ -28285,32 +28286,37 @@ async function run() {
}

const joinTags = (tags) => tags.map((v) => `type=raw,${v}`).join(",");

magento.push({
artifact: version + variation.suffix,
mariadb: context.mariadb,
php: context.php,
opensearch: context.opensearch,
kind: variation.kind,
magentoVersion: version,
stability: context.stability ? context.stability : "stable",
containers: JSON.stringify([
containers.push(
...[
{
artifact: version + variation.suffix,
tag: joinTags(tags),
containerType: "mysql",
version: context.mysql,
},
{
artifact: version + variation.suffix,
tag: joinTags(tags),
containerType: "mariadb",
version: context.mariadb,
},
{
artifact: version + variation.suffix,
tag: joinTags(tags),
containerType: "opensearch",
version: context.opensearch,
},
]),
],
);

magento.push({
artifact: version + variation.suffix,
mariadb: context.mariadb,
php: context.php,
opensearch: context.opensearch,
kind: variation.kind,
magentoVersion: version,
stability: context.stability ? context.stability : "stable",
});
}
}
Expand All @@ -28323,6 +28329,7 @@ async function run() {
return;
}
(0,core.setOutput)("magento", JSON.stringify(magento));
(0,core.setOutput)("containers", JSON.stringify(containers));
(0,core.info)(
`Successfully generated matrix for execution with versions: ${magento.map((v) => v.magentoVersion).join(",")}`,
);
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/generate-matrix/dist/index.js.map

Large diffs are not rendered by default.

29 changes: 18 additions & 11 deletions .github/actions/generate-matrix/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import semver from "semver";

export async function run() {
const magento = [];
const containers = [];
const requestedVersion = getInput("version");
const requestedVariation = getInput("variation");
for (const variation of variations) {
Expand Down Expand Up @@ -32,32 +33,37 @@ export async function run() {
}

const joinTags = (tags) => tags.map((v) => `type=raw,${v}`).join(",");

magento.push({
artifact: version + variation.suffix,
mariadb: context.mariadb,
php: context.php,
opensearch: context.opensearch,
kind: variation.kind,
magentoVersion: version,
stability: context.stability ? context.stability : "stable",
containers: JSON.stringify([
containers.push(
...[
{
artifact: version + variation.suffix,
tag: joinTags(tags),
containerType: "mysql",
version: context.mysql,
},
{
artifact: version + variation.suffix,
tag: joinTags(tags),
containerType: "mariadb",
version: context.mariadb,
},
{
artifact: version + variation.suffix,
tag: joinTags(tags),
containerType: "opensearch",
version: context.opensearch,
},
]),
],
);

magento.push({
artifact: version + variation.suffix,
mariadb: context.mariadb,
php: context.php,
opensearch: context.opensearch,
kind: variation.kind,
magentoVersion: version,
stability: context.stability ? context.stability : "stable",
});
}
}
Expand All @@ -70,6 +76,7 @@ export async function run() {
return;
}
setOutput("magento", JSON.stringify(magento));
setOutput("containers", JSON.stringify(containers));
info(
`Successfully generated matrix for execution with versions: ${magento.map((v) => v.magentoVersion).join(",")}`,
);
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
magento: ${{ steps.matrix.outputs.magento }}
containers: ${{ steps.matrix.outputs.containers }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/generate-matrix
Expand All @@ -39,9 +40,6 @@ jobs:
strategy:
matrix:
include: ${{ fromJson(needs.generate-matrix.outputs.magento) }}
outputs:
containers: ${{ steps.build.outputs.containers }}
artifact: ${{ steps.build.outputs.artifact }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-magento
Expand All @@ -52,27 +50,26 @@ jobs:
php: ${{ matrix.php }}
version: ${{ matrix.magentoVersion }}
kind: ${{ matrix.kind }}
containers: ${{ matrix.containers }}
stability: ${{ matrix.stability }}
composerAuth: ${{ secrets.COMPOSER_AUTH }}
composerRepository: 'https://repo.magento.com/'
id: build
build-container:
runs-on: ubuntu-latest
needs: build-magento
needs: [generate-matrix, build-magento]
permissions:
packages: write
contents: read
attestations: write
id-token: write
strategy:
matrix:
include: ${{ fromJson(needs.build-magento.outputs.containers) }}
include: ${{ fromJson(needs.generate-matrix.outputs.containers) }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-image
with:
artifact: ${{ needs.build-magento.outputs.artifact }}
artifact: ${{ matrix.artifact }}
containerType: ${{ matrix.containerType }}
imageName: ${{ github.repository_owner }}/testcontainer-magento-${{ matrix.containerType }}
imageTags: ${{ matrix.tag }}
Expand Down

0 comments on commit aadfed7

Please sign in to comment.