File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
actions/docker/get-image-metadata Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 6060
6161 const tagsOutput = `${{ steps.get-image-metadata.outputs.tags }}`;
6262 assert(tagsOutput.length, `"tags" output is empty`);
63- assert(tagsOutput.startsWith("ghcr.io/hoverkraft-tech/ci-github-container/application-test:"), `"tags" output is not valid`);
63+
64+ const tags = tagsOutput.split("\n").filter(Boolean);
65+ assert(tags.length, `"tags" output is empty`);
66+
67+ if (`${{ github.event_name }}` === "pull_request") {
68+ assert.equal(
69+ tags.length,
70+ 2,
71+ `"tags" output must contain 2 tags for pull_request event`
72+ );
73+
74+ assert(
75+ tags[0].startsWith("ghcr.io/hoverkraft-tech/ci-github-container/application-test:pr-${{ github.event.pull_request.number }}-"),
76+ `"tags" output is not valid`
77+ );
78+
79+ assert.equal(
80+ tags[1],
81+ "ghcr.io/hoverkraft-tech/ci-github-container/application-test:pr-${{ github.event.pull_request.number }}", `"tags" output is not valid`
82+ );
83+ } else {
84+ assert.equal(
85+ tags.length,
86+ 2,
87+ `"tags" output must contain 2 tags for push event`
88+ );
89+
90+ assert.equal(tag[0],"ghcr.io/hoverkraft-tech/ci-github-container/application-test:main", `"tags" output is not valid`);
91+ assert.equal(tags[1],"ghcr.io/hoverkraft-tech/ci-github-container/application-test:latest", `"tags" output is not valid`);
92+ }
6493
6594 tests-with-given-tag :
6695 name : Test for "docker/get-image-metadata" action with given tag
Original file line number Diff line number Diff line change 6767 result-encoding : string
6868 script : |
6969 // If push on default branch set tag to latest
70- const isPushOnDefaultBranch = context.eventName === 'push' && context .ref === `refs/heads/ ${{ github.base_ref }}`;
70+ const isPushOnDefaultBranch = context.eventName === 'push' && `${{ github .ref }}` === `${{ github.event.repository.default_branch }}`;
7171 core.setOutput('flavor', isPushOnDefaultBranch ? 'latest=true' : 'latest=false');
7272
7373 const tagInput = `${{ inputs.tag }}`
You can’t perform that action at this time.
0 commit comments