Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
feat: virtual project for specific file (#55)
Browse files Browse the repository at this point in the history
* ci: upload specific file

* feat: specific file overrides default project

* feat: build new feature
  • Loading branch information
AlexShemeshWix authored Mar 10, 2021
1 parent f06d904 commit 33334d5
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 7 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ inputs:
publishAsVirtualProject:
required: false
description: ' Name of the virtual project to create link.Usefull for creating latest version links.'
specificFile:
required: false
description: 'file in s3Subfolder to upload'
runs:
using: 'node12'
main: 'dist/index.js'
26 changes: 24 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,23 @@ export class AWSS3Client {
} as AWS.S3.PutObjectRequest)
.promise()
}

async updateLatestWithSpecificFile(
s3BucketName: string,
targetSubfolder: string,
projectName: string,
specificFile: string
): Promise<void> {
const linkText = `<meta http-equiv="refresh" content="0; URL=https://bo.wix.com/core3-proxy/${targetSubfolder}/${specificFile}"/>`
const targetPath = `${projectName}/index.html`
await this.s3Client
.putObject({
Bucket: s3BucketName,
Key: targetPath,
Body: linkText,
ContentType: 'text/html;charset=UTF-8',
Tagging: 'Buisness Unit=core3'
} as AWS.S3.PutObjectRequest)
.promise()
}
}
21 changes: 17 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,27 @@ async function run(): Promise<void> {
const sourceFolder: string = core.getInput('sourceFolder')
const tags: string = core.getInput('tags')
const publishAsProject: string = core.getInput('publishAsVirtualProject')
const specificFile: string = core.getInput('specificFile')
core.info(`Uploading ${sourceFolder} to ${awsBucket}/${s3Subfolder}`)
const s3Client = new AWSS3Client(accessKeyId, secretAccessKey)
await s3Client.uploadFolder(awsBucket, s3Subfolder, sourceFolder, tags)
if (publishAsProject && publishAsProject !== '') {
await s3Client.updateLatest(awsBucket, s3Subfolder, publishAsProject)
core.info(
`Create static link ${awsBucket}/${publishAsProject} for ${awsBucket}/${s3Subfolder}`
)
if (specificFile !== '') {
await s3Client.updateLatestWithSpecificFile(
awsBucket,
s3Subfolder,
publishAsProject,
specificFile
)
core.info(
`Create static link ${awsBucket}/${publishAsProject} for ${awsBucket}/${s3Subfolder}/${specificFile}`
)
} else {
await s3Client.updateLatest(awsBucket, s3Subfolder, publishAsProject)
core.info(
`Create static link ${awsBucket}/${publishAsProject} for ${awsBucket}/${s3Subfolder}`
)
}
}
core.info('Done')
} catch (error) {
Expand Down

0 comments on commit 33334d5

Please sign in to comment.