@@ -27,15 +27,23 @@ jobs:
2727
2828 - name : Assert - Check get image metadata ouputs
2929 uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
30+ env :
31+ IMAGE_OUTPUT : ${{ steps.get-image-metadata.outputs.image }}
32+ LABELS_OUTPUT : ${{ steps.get-image-metadata.outputs.labels }}
33+ ANNOTATIONS_OUTPUT : ${{ steps.get-image-metadata.outputs.annotations }}
34+ TAGS_OUTPUT : ${{ steps.get-image-metadata.outputs.tags }}
3035 with :
3136 script : |
3237 const assert = require("assert");
38+ const pullRequestNumber = context.payload.pull_request?.number;
39+ const refName = process.env.GITHUB_REF_NAME;
40+ const defaultBranch = context.payload.repository?.default_branch;
3341
34- const imageOutput = `${{ steps.get-image-metadata.outputs.image }}` ;
42+ const imageOutput = process.env.IMAGE_OUTPUT ;
3543 assert(imageOutput.length, `"image" output is empty`);
3644 assert.equal(imageOutput,"ghcr.io/hoverkraft-tech/ci-github-container/application-test", `"image" output is not valid`);
3745
38- const labelsOutput = `${{ steps.get-image-metadata.outputs.labels }}` ;
46+ const labelsOutput = process.env.LABELS_OUTPUT ;
3947 assert(labelsOutput.length, `"labels" output is empty`);
4048 assert(
4149 labelsOutput.startsWith("org.opencontainers.image.created"),
5159 `"labels" output is not valid`
5260 );
5361
54- const annotationsOutput = `${{ steps.get-image-metadata.outputs.annotations }}` ;
62+ const annotationsOutput = process.env.ANNOTATIONS_OUTPUT ;
5563 assert(annotationsOutput.length, `"annotations" output is empty`);
5664
5765 const expectedManifestAnnotations = expectedLabels.split("\n").map(line => {
@@ -74,26 +82,26 @@ jobs:
7482 `"annotations - manifest-descriptor" output is not valid`
7583 );
7684
77- const tagsOutput = `${{ steps.get-image-metadata.outputs.tags }}` ;
85+ const tagsOutput = process.env.TAGS_OUTPUT ;
7886 assert(tagsOutput.length, `"tags" output is empty`);
7987
8088 const tags = tagsOutput.split("\n").filter(Boolean);
8189 assert(tags.length, `"tags" output is empty`);
8290
8391 const expectedTags = [];
8492
85- if (`${{ github.event_name }}` === "pull_request") {
86- const shortSha = `${{ github .sha }}` .substring(0, 7);
87- const prShaTag = `pr-${{ github.event.pull_request.number } }-${shortSha}`;
88- const prTag = `pr-${{ github.event.pull_request.number } }`;
93+ if (context.eventName === "pull_request") {
94+ const shortSha = context .sha.substring(0, 7);
95+ const prShaTag = `pr-${pullRequestNumber }-${shortSha}`;
96+ const prTag = `pr-${pullRequestNumber }`;
8997
9098 expectedTags.push(prShaTag, prTag);
9199 } else {
92- const refTag = `${{ github.ref_name }}` ;
100+ const refTag = refName ;
93101 expectedTags.push(refTag);
94102
95- const isTag = `${{ github .ref }}` .startsWith('refs/tags/');
96- const isPushOnDefaultBranch = `${{ github.event_name }}` === "push" && !isTag && refTag === "${{ github.event.repository.default_branch }}" ;
103+ const isTag = context .ref.startsWith('refs/tags/');
104+ const isPushOnDefaultBranch = context.eventName === "push" && !isTag && refTag === defaultBranch ;
97105
98106 if (isPushOnDefaultBranch) {
99107 expectedTags.push("latest");
@@ -103,7 +111,7 @@ jobs:
103111 assert.equal(
104112 tags.length,
105113 expectedTags.length,
106- `"tags" output must contain ${expectedTags.length} tags for ${{ github.event_name } } event`
114+ `"tags" output must contain ${expectedTags.length} tags for ${context.eventName } event`
107115 );
108116
109117 for(const expectedTag of expectedTags) {
@@ -134,11 +142,13 @@ jobs:
134142
135143 - name : Assert - Check get image metadata ouputs
136144 uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
145+ env :
146+ TAGS_OUTPUT : ${{ steps.get-image-metadata.outputs.tags }}
137147 with :
138148 script : |
139149 const assert = require("assert");
140150
141- const tagsOutput = `${{ steps.get-image-metadata.outputs.tags }}` ;
151+ const tagsOutput = process.env.TAGS_OUTPUT ;
142152 assert(tagsOutput.length, `"tags" output is empty`);
143153 assert.equal(
144154 tagsOutput,
0 commit comments