make sure to populate outputs of the composite action, Disable attestations

This commit is contained in:
boxofyellow
2024-01-26 14:49:48 -05:00
committed by Edwin Sirko
parent 5f9b214e33
commit db688d0eea
5 changed files with 32 additions and 24 deletions
+10 -6
View File
@@ -24,6 +24,7 @@ let isDirectoryMock: jest.SpyInstance
let createArchivesMock: jest.SpyInstance
let removeDirMock: jest.SpyInstance
let bundleFilesintoDirectoryMock: jest.SpyInstance
let isActionRepoMock: jest.SpyInstance
// Mock the GHCR Client
let publishOCIArtifactMock: jest.SpyInstance
@@ -49,6 +50,7 @@ describe('action', () => {
bundleFilesintoDirectoryMock = jest
.spyOn(fsHelper, 'bundleFilesintoDirectory')
.mockImplementation()
isActionRepoMock = jest.spyOn(fsHelper, 'isActionRepo').mockImplementation()
// GHCR Client mocks
publishOCIArtifactMock = jest
@@ -61,7 +63,7 @@ describe('action', () => {
process.env.GITHUB_REPOSITORY = ''
// Run the action
await main.run()
await main.run('directory1 directory2')
// Check the results
expect(setFailedMock).toHaveBeenCalledWith('Could not find Repository.')
@@ -73,7 +75,7 @@ describe('action', () => {
github.context.eventName = 'push'
// Run the action
await main.run()
await main.run('directory1 directory2')
// Check the results
expect(setFailedMock).toHaveBeenCalledWith(
@@ -93,7 +95,7 @@ describe('action', () => {
}
// Run the action
await main.run()
await main.run('directory1 directory2')
// Check the results
expect(setFailedMock).toHaveBeenCalledWith(
@@ -127,7 +129,7 @@ describe('action', () => {
})
// Run the action
await main.run()
await main.run('directory1 directory2')
// Check the results
expect(setFailedMock).toHaveBeenCalledWith('Something went wrong')
@@ -153,6 +155,7 @@ describe('action', () => {
})
isDirectoryMock.mockImplementation(() => true)
isActionRepoMock.mockImplementation(() => true)
createTempDirMock.mockImplementation(() => '/tmp/test')
@@ -161,7 +164,7 @@ describe('action', () => {
})
// Run the action
await main.run()
await main.run('directory')
// Check the results
expect(isDirectoryMock).toHaveBeenCalledWith('directory')
@@ -205,6 +208,7 @@ async function testHappyPath(version: string, path: string): Promise<void> {
})
isDirectoryMock.mockImplementation(() => true)
isActionRepoMock.mockImplementation(() => true)
bundleFilesintoDirectoryMock.mockImplementation(() => {
return '/tmp/test'
@@ -232,7 +236,7 @@ async function testHappyPath(version: string, path: string): Promise<void> {
})
// Run the action
await main.run()
await main.run(path)
expect(publishOCIArtifactMock).toHaveBeenCalledTimes(1)
+10 -7
View File
@@ -15,10 +15,13 @@ inputs:
outputs:
package-url:
description: 'The name of package published to GHCR along with semver. For example, https://ghcr.io/actions/package-action:1.0.1'
value: ${{steps.publish.outputs.package-url}}
package-manifest:
description: 'The package manifest of the published package in JSON format'
value: ${{steps.publish.outputs.package-manifest}}
package-manifest-sha:
description: 'A sha256 hash of the package manifest'
value: ${{steps.publish.outputs.package-manifest-sha}}
runs:
using: 'composite'
steps:
@@ -36,10 +39,10 @@ runs:
echo "package manifest sha": ${{steps.publish.outputs.package-manifest-sha}}
echo "package url": ${{steps.publish.outputs.package-url}}
echo "subject name": ${{github.repository}}_${{github.ref}}
- name: Generate Provenance Attestation
uses: github-early-access/generate-build-provenance@main
id: build-provenance
with:
subject-name: ${{github.repository}}_${{github.ref}}
subject-digest: ${{steps.publish.outputs.package-manifest-sha}}
push-to-registry: false
# - name: Generate Provenance Attestation
# uses: github-early-access/generate-build-provenance@main
# id: build-provenance
# with:
# subject-name: ${{github.repository}}_${{github.ref}}
# subject-digest: ${{steps.publish.outputs.package-manifest-sha}}
# push-to-registry: false
+1 -1
View File
@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="116" height="20" role="img" aria-label="Coverage: 95.05%"><title>Coverage: 95.05%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#4c1"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">95.05%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">95.05%</text></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="116" height="20" role="img" aria-label="Coverage: 93.81%"><title>Coverage: 93.81%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#4c1"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">93.81%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">93.81%</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Generated Vendored
+9 -8
View File
@@ -75061,13 +75061,6 @@ async function run(pathInput) {
return;
}
const token = process.env.TOKEN;
const response = await fetch(process.env.GITHUB_API_URL + '/packages/container-registry-url');
if (!response.ok) {
throw new Error(`Failed to fetch status page: ${response.statusText}`);
}
const data = await response.json();
const registryURL = new URL(data.url);
console.log(`Container registry URL: ${registryURL}`);
// Gather & validate user input
// Paths to be included in the OCI image
// const paths: string[] = core.getInput('path').split(' ')
@@ -75097,6 +75090,13 @@ async function run(pathInput) {
const manifestHash = manifestSHA
.update(JSON.stringify(manifest))
.digest('hex');
const response = await fetch(`${process.env.GITHUB_API_URL}/packages/container-registry-url`);
if (!response.ok) {
throw new Error(`Failed to fetch status page: ${response.statusText}`);
}
const data = await response.json();
const registryURL = new URL(data.url);
console.log(`Container registry URL: ${registryURL}`);
const packageURL = await ghcr.publishOCIArtifact(token, registryURL, repository, releaseId.toString(), targetVersion.raw, archives.zipFile, archives.tarFile, manifest, true);
core.setOutput('package-url', packageURL.toString());
core.setOutput('package-manifest', JSON.stringify(manifest));
@@ -75104,7 +75104,8 @@ async function run(pathInput) {
}
catch (error) {
// Fail the workflow run if an error occurs
// if (error instanceof Error) core.setFailed(error.message)
if (error instanceof Error)
core.setFailed(error.message);
}
finally {
// Clean up any temporary directories that exist
+2 -2
View File
@@ -85,7 +85,7 @@ export async function run(pathInput: string): Promise<void> {
.digest('hex')
const response = await fetch(
process.env.GITHUB_API_URL + '/packages/container-registry-url'
`${process.env.GITHUB_API_URL}/packages/container-registry-url`
)
if (!response.ok) {
throw new Error(`Failed to fetch status page: ${response.statusText}`)
@@ -111,7 +111,7 @@ export async function run(pathInput: string): Promise<void> {
core.setOutput('package-manifest-sha', `sha256:${manifestHash}`)
} catch (error) {
// Fail the workflow run if an error occurs
// if (error instanceof Error) core.setFailed(error.message)
if (error instanceof Error) core.setFailed(error.message)
} finally {
// Clean up any temporary directories that exist
for (const tmpDir of tmpDirs) {