use GITHUB_WORKSPACE as target dir to package up
This commit is contained in:
@@ -64,8 +64,22 @@ describe('run', () => {
|
|||||||
.mockImplementation()
|
.mockImplementation()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('fails if no action workspace found', async () => {
|
||||||
|
// Mock the environment
|
||||||
|
process.env.GITHUB_WORKSPACE = ''
|
||||||
|
|
||||||
|
// Run the action
|
||||||
|
await main.run()
|
||||||
|
|
||||||
|
// Check the results
|
||||||
|
expect(setFailedMock).toHaveBeenCalledWith(
|
||||||
|
'Could not find GITHUB_WORKSPACE.'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
it('fails if no repository found', async () => {
|
it('fails if no repository found', async () => {
|
||||||
// Mock the environment
|
// Mock the environment
|
||||||
|
process.env.GITHUB_WORKSPACE = '.'
|
||||||
process.env.GITHUB_REPOSITORY = ''
|
process.env.GITHUB_REPOSITORY = ''
|
||||||
|
|
||||||
// Run the action
|
// Run the action
|
||||||
@@ -77,6 +91,7 @@ describe('run', () => {
|
|||||||
|
|
||||||
it('fails if no token found', async () => {
|
it('fails if no token found', async () => {
|
||||||
// Mock the environment
|
// Mock the environment
|
||||||
|
process.env.GITHUB_WORKSPACE = '.'
|
||||||
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
process.env.TOKEN = ''
|
process.env.TOKEN = ''
|
||||||
|
|
||||||
@@ -89,6 +104,7 @@ describe('run', () => {
|
|||||||
|
|
||||||
it('fails if no source commit found', async () => {
|
it('fails if no source commit found', async () => {
|
||||||
// Mock the environment
|
// Mock the environment
|
||||||
|
process.env.GITHUB_WORKSPACE = '.'
|
||||||
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
process.env.TOKEN = 'test'
|
process.env.TOKEN = 'test'
|
||||||
process.env.GITHUB_SHA = ''
|
process.env.GITHUB_SHA = ''
|
||||||
@@ -101,6 +117,7 @@ describe('run', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('fails if trigger is not release or tag push', async () => {
|
it('fails if trigger is not release or tag push', async () => {
|
||||||
|
process.env.GITHUB_WORKSPACE = '.'
|
||||||
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
process.env.GITHUB_SHA = 'test-sha'
|
process.env.GITHUB_SHA = 'test-sha'
|
||||||
process.env.TOKEN = 'token'
|
process.env.TOKEN = 'token'
|
||||||
@@ -117,6 +134,7 @@ describe('run', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('fails if the trigger is a push, but not a tag push', async () => {
|
it('fails if the trigger is a push, but not a tag push', async () => {
|
||||||
|
process.env.GITHUB_WORKSPACE = '.'
|
||||||
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
process.env.GITHUB_SHA = 'test-sha'
|
process.env.GITHUB_SHA = 'test-sha'
|
||||||
process.env.TOKEN = 'token'
|
process.env.TOKEN = 'token'
|
||||||
@@ -131,6 +149,7 @@ describe('run', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('fails if the value of the tag input is not a valid semver', async () => {
|
it('fails if the value of the tag input is not a valid semver', async () => {
|
||||||
|
process.env.GITHUB_WORKSPACE = '.'
|
||||||
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
process.env.GITHUB_SHA = 'test-sha'
|
process.env.GITHUB_SHA = 'test-sha'
|
||||||
process.env.TOKEN = 'token'
|
process.env.TOKEN = 'token'
|
||||||
@@ -155,6 +174,7 @@ describe('run', () => {
|
|||||||
|
|
||||||
it('fails if staging files fails', async () => {
|
it('fails if staging files fails', async () => {
|
||||||
// Mock the environment
|
// Mock the environment
|
||||||
|
process.env.GITHUB_WORKSPACE = '.'
|
||||||
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
github.context.eventName = 'release'
|
github.context.eventName = 'release'
|
||||||
process.env.GITHUB_SHA = 'test-sha'
|
process.env.GITHUB_SHA = 'test-sha'
|
||||||
@@ -179,6 +199,7 @@ describe('run', () => {
|
|||||||
|
|
||||||
it('fails if creating temp directory fails', async () => {
|
it('fails if creating temp directory fails', async () => {
|
||||||
// Mock the environment
|
// Mock the environment
|
||||||
|
process.env.GITHUB_WORKSPACE = '.'
|
||||||
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
github.context.eventName = 'release'
|
github.context.eventName = 'release'
|
||||||
process.env.GITHUB_SHA = 'test-sha'
|
process.env.GITHUB_SHA = 'test-sha'
|
||||||
@@ -203,6 +224,7 @@ describe('run', () => {
|
|||||||
|
|
||||||
it('fails if creating archives fails', async () => {
|
it('fails if creating archives fails', async () => {
|
||||||
// Mock the environment
|
// Mock the environment
|
||||||
|
process.env.GITHUB_WORKSPACE = '.'
|
||||||
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
github.context.eventName = 'release'
|
github.context.eventName = 'release'
|
||||||
process.env.GITHUB_SHA = 'test-sha'
|
process.env.GITHUB_SHA = 'test-sha'
|
||||||
@@ -226,6 +248,7 @@ describe('run', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('fails if getting container registry URL fails', async () => {
|
it('fails if getting container registry URL fails', async () => {
|
||||||
|
process.env.GITHUB_WORKSPACE = '.'
|
||||||
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
github.context.eventName = 'release'
|
github.context.eventName = 'release'
|
||||||
process.env.GITHUB_SHA = 'test-sha'
|
process.env.GITHUB_SHA = 'test-sha'
|
||||||
@@ -268,6 +291,7 @@ describe('run', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('fails if publishing OCI artifact fails', async () => {
|
it('fails if publishing OCI artifact fails', async () => {
|
||||||
|
process.env.GITHUB_WORKSPACE = '.'
|
||||||
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
github.context.eventName = 'release'
|
github.context.eventName = 'release'
|
||||||
process.env.GITHUB_SHA = 'test-sha'
|
process.env.GITHUB_SHA = 'test-sha'
|
||||||
@@ -314,6 +338,7 @@ describe('run', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('uploads the artifact, returns package metadata from GHCR, and cleans up tmp dirs', async () => {
|
it('uploads the artifact, returns package metadata from GHCR, and cleans up tmp dirs', async () => {
|
||||||
|
process.env.GITHUB_WORKSPACE = '.'
|
||||||
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
process.env.GITHUB_REPOSITORY = 'test-org/test-repo'
|
||||||
github.context.eventName = 'release'
|
github.context.eventName = 'release'
|
||||||
process.env.GITHUB_SHA = 'test-sha'
|
process.env.GITHUB_SHA = 'test-sha'
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ runs:
|
|||||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
GITHUB_REPOSITORY: ${{ github.repository }}
|
||||||
GITHUB_REF: ${{ github.ref }}
|
GITHUB_REF: ${{ github.ref }}
|
||||||
GITHUB_SHA: ${{ github.sha }}
|
GITHUB_SHA: ${{ github.sha }}
|
||||||
|
GITHUB_WORKSPACE: ${{ github.workspace }}
|
||||||
- name: Output variables
|
- name: Output variables
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
+497
-406
File diff suppressed because it is too large
Load Diff
+7
-1
@@ -12,6 +12,12 @@ import semver from 'semver'
|
|||||||
*/
|
*/
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
const workspace: string = process.env.GITHUB_WORKSPACE || ''
|
||||||
|
if (workspace === '') {
|
||||||
|
core.setFailed(`Could not find GITHUB_WORKSPACE.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const repository: string = process.env.GITHUB_REPOSITORY || ''
|
const repository: string = process.env.GITHUB_REPOSITORY || ''
|
||||||
if (repository === '') {
|
if (repository === '') {
|
||||||
core.setFailed(`Could not find Repository.`)
|
core.setFailed(`Could not find Repository.`)
|
||||||
@@ -33,7 +39,7 @@ export async function run(): Promise<void> {
|
|||||||
|
|
||||||
// Create a temporary directory to stage files for packaging in archives
|
// Create a temporary directory to stage files for packaging in archives
|
||||||
const stagedActionFilesDir = fsHelper.createTempDir('staging')
|
const stagedActionFilesDir = fsHelper.createTempDir('staging')
|
||||||
fsHelper.stageActionFiles('.', stagedActionFilesDir)
|
fsHelper.stageActionFiles(workspace, stagedActionFilesDir)
|
||||||
|
|
||||||
// Create a temporary directory to store the archives
|
// Create a temporary directory to store the archives
|
||||||
const archiveDir = fsHelper.createTempDir('archive')
|
const archiveDir = fsHelper.createTempDir('archive')
|
||||||
|
|||||||
Reference in New Issue
Block a user