Skip to content

Commit 5d70e27

Browse files
committed
wip: testing
1 parent c5314c8 commit 5d70e27

File tree

4 files changed

+131
-37
lines changed

4 files changed

+131
-37
lines changed

.github/workflows/publish.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,30 @@ jobs:
3131
uses: ./forge/actions/run
3232
with:
3333
path: ${{ matrix.earthfile }}
34-
- name: Get image
34+
- name: Get image and project
3535
id: image
3636
run: |
3737
EARTHFILE='${{ matrix.earthfile }}'
38-
FILE="${EARTHFILE%+*}"
38+
PROJECT="${EARTHFILE%+*}"
3939
TARGET="${EARTHFILE#*+}"
4040
RESULT='${{ steps.run.outputs.result }}'
4141
42-
# If the path is just ".", then we omit it
43-
if [[ "$FILE" == "." ]]; then
42+
# If the path to the project is just ".", then we omit it
43+
if [[ "$PROJECT" == "." ]]; then
4444
EARTHFILE="+$TARGET"
4545
fi
4646
4747
IMAGE="$(echo "$RESULT" | jq -r ".images[\"$EARTHFILE\"]")"
4848
4949
if [[ "$IMAGE" == "null" ]]; then
50-
echo "::error file=${FILE}/Earthfile::No images produced. Cannot publish."
50+
echo "::error file=${PROJECT}/Earthfile::No images produced. Cannot publish."
5151
exit 1
5252
fi
5353
5454
echo "image=$IMAGE" >> $GITHUB_OUTPUT
55-
- name: Show image
56-
run: echo "${{ steps.image.outputs.image }}"
55+
echo "project=$PROJECT" >> $GITHUB_OUTPUT
56+
- name: Publish
57+
uses: ./forge/actions/publish
58+
with:
59+
image: ${{ steps.image.outputs.image }}
60+
project: ${{ steps.image.outputs.project }}

forge/actions/publish/dist/index.js

Lines changed: 98 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

forge/actions/publish/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

forge/actions/publish/src/main.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,31 @@ async function run() {
77
const image = core.getInput("image", { required: true });
88

99
if (!imageExists(image)) {
10-
core.setFailed(`Image ${image} does not exist in the local Docker daemon`);
10+
core.setFailed(
11+
`Image ${image} does not exist in the local Docker daemon`,
12+
);
1113
return;
1214
}
1315

1416
const blueprint = await getBlueprint(project);
1517

1618
if (blueprint?.project?.container === undefined) {
17-
core.warning(`Project ${project} does not have a container defined. Skipping publish`);
19+
core.warning(
20+
`Project ${project} does not have a container defined. Skipping publish`,
21+
);
1822
return;
1923
} else if (blueprint?.global?.tagging?.strategy === undefined) {
20-
core.warning(`The repository does not have a tagging strategy defined. Skipping publish`);
24+
core.warning(
25+
`The repository does not have a tagging strategy defined. Skipping publish`,
26+
);
2127
return;
22-
} else if (blueprint?.global?.registry === undefined || blueprint?.global?.registry.length === 0) {
23-
core.warning(`The repository does not have any registries defined. Skipping publish`);
28+
} else if (
29+
blueprint?.global?.registry === undefined ||
30+
blueprint?.global?.registry.length === 0
31+
) {
32+
core.warning(
33+
`The repository does not have any registries defined. Skipping publish`,
34+
);
2435
return;
2536
}
2637

@@ -52,7 +63,9 @@ module.exports = {
5263
* @returns {object} The blueprint object
5364
*/
5465
async function getBlueprint(project) {
55-
return JSON.parse(await exec.getExecOutput("forge", ["blueprint", "dump", project]));
66+
return JSON.parse(
67+
await exec.getExecOutput("forge", ["blueprint", "dump", project]),
68+
);
5669
}
5770

5871
/**
@@ -77,7 +90,7 @@ function getTag(strategy) {
7790
* @return {boolean} True if the image exists, false otherwise
7891
*/
7992
async function imageExists(name) {
80-
ret = await exec.exec("docker", ["inspect", name]);
93+
const ret = await exec.exec("docker", ["inspect", name]);
8194
return ret === 0;
8295
}
8396

@@ -103,4 +116,4 @@ function strategyCommit() {
103116
*/
104117
async function tagImage(oldImage, newImage) {
105118
await exec.exec("docker", ["tag", oldImage, newImage]);
106-
}
119+
}

0 commit comments

Comments
 (0)