mirror of
https://github.com/actions/attest-build-provenance.git
synced 2026-06-13 18:19:53 +00:00
Merge pull request #2 from GIgako19929/update-main-function
Update main function to process images and handle errors
This commit is contained in:
commit
5eedf3cf42
@ -1 +1,2 @@
|
||||
20.6.0
|
||||
|
||||
|
||||
@ -183,4 +183,27 @@ describe('main', () => {
|
||||
expect(outputs['predicate-type']).toBe('https://slsa.dev/provenance/v1')
|
||||
})
|
||||
})
|
||||
|
||||
describe('when an error occurs during processing', () => {
|
||||
beforeEach(() => {
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
GITHUB_SERVER_URL: 'https://github.com',
|
||||
GITHUB_REPOSITORY: 'owner/repo'
|
||||
}
|
||||
})
|
||||
|
||||
it('fails the workflow run', async () => {
|
||||
jest.spyOn(core, 'getInput').mockImplementation((name) => {
|
||||
if (name === 'subject-images') {
|
||||
throw new Error('Test error')
|
||||
}
|
||||
return ''
|
||||
})
|
||||
|
||||
await main.run()
|
||||
|
||||
expect(setFailedMock).toHaveBeenCalledWith('Test error')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
12
src/main.ts
12
src/main.ts
@ -14,6 +14,8 @@ export async function run(): Promise<void> {
|
||||
for (const image of images) {
|
||||
core.info(`Processing image: ${image}`)
|
||||
// Add logic to process each image for attestation
|
||||
// Assuming processImageForAttestation is a function that processes the image
|
||||
await processImageForAttestation(image)
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,3 +30,13 @@ export async function run(): Promise<void> {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes an image for attestation.
|
||||
* @param {string} image - The image to process.
|
||||
* @returns {Promise<void>} Resolves when the image is processed.
|
||||
*/
|
||||
async function processImageForAttestation(image: string): Promise<void> {
|
||||
// Add the actual logic to process the image for attestation
|
||||
core.info(`Image ${image} processed for attestation`)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user