Skip to content

Commit

Permalink
fix: deploy 4
Browse files Browse the repository at this point in the history
  • Loading branch information
arpowers committed Mar 3, 2024
1 parent 0b7a4a6 commit dcf296a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ jobs:
"text": "Workflow *${{ github.workflow }}* on *${{ github.ref }}* (commit: ${{ github.sha }}) completed with status: *${{ job.status }}*. <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run>"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
73 changes: 38 additions & 35 deletions @fiction/core/plugin-aws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,29 @@ export class FictionAws extends FictionPlugin<FictionAwsSettings> {
}> => {
if (!bucket)
throw new Error('no bucket set')
const s3 = await this.getS3()

const result: PutObjectCommandOutput = await s3.putObject({
Body: data,
Bucket: bucket,
Key: filePath,
ContentType: mime,
ACL: accessControl,
})
try {
const s3 = await this.getS3()

const headObject = await s3.headObject({ Bucket: bucket, Key: filePath })
const result: PutObjectCommandOutput = await s3.putObject({
Body: data,
Bucket: bucket,
Key: filePath,
ContentType: mime,
ACL: accessControl,
})

const headObject = await s3.headObject({ Bucket: bucket, Key: filePath })

return {
url: `https://${bucket}.s3.amazonaws.com/${filePath}`,
result,
headObject,
return {
url: `https://${bucket}.s3.amazonaws.com/${filePath}`,
result,
headObject,
}
}
catch (e) {
this.log.error('uploadS3 error', { data: { filePath, bucket, mime, region: this.region } })
throw e
}
}

Expand All @@ -154,25 +161,26 @@ export class FictionAws extends FictionPlugin<FictionAwsSettings> {

const s3 = await this.getS3()

const r = await s3.listObjectsV2({
Bucket: bucket,
Prefix: directory,
})
try {
const r = await s3.listObjectsV2({ Bucket: bucket, Prefix: directory })

const keys = r.Contents?.map(item => ({ Key: item.Key })) || []
const keys = r.Contents?.map(item => ({ Key: item.Key })) || []

this.log.warn(`deleting directory ${directory}`, { data: keys, r })
this.log.warn(`deleting directory ${directory}`, { data: keys, r })

const result = await s3.deleteObjects({
Bucket: bucket,
Delete: {
Objects: keys,
Quiet: false,
},
})
const result = await s3.deleteObjects({
Bucket: bucket,
Delete: {
Objects: keys,
Quiet: false,
},
})

return {
result,
return { result }
}
catch (e) {
this.log.error('deleteDirectory error', { data: { directory, bucket, region: this.region } })
throw e
}
}

Expand All @@ -181,14 +189,9 @@ export class FictionAws extends FictionPlugin<FictionAwsSettings> {
throw new Error('no bucket set')
const s3 = await this.getS3()

const result = await s3.deleteObject({
Bucket: bucket,
Key: filePath,
})
const result = await s3.deleteObject({ Bucket: bucket, Key: filePath })

return {
result,
}
return { result }
}

/**
Expand Down
2 changes: 1 addition & 1 deletion @fiction/plugin-sites/test/siteTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function createSiteTestUtils(): Promise<SiteTestUtils> {

out.fictionAi = new FictionAi({ ...out, openaiApiKey })
out.fictionAws = new FictionAws({ fictionEnv, awsAccessKey, awsAccessKeySecret })
out.fictionMedia = new FictionMedia({ ...out, fictionAws: out.fictionAws, bucket: 'fiction-tests' })
out.fictionMedia = new FictionMedia({ ...out, fictionAws: out.fictionAws, bucket: 'factor-tests' })
out.fictionRouterSites = new FictionRouter({ routerId: 'siteRouter', fictionEnv, baseUrl: 'https://www.test.com', routes, create: true })
out.fictionAppSites = new FictionApp({
port: randomBetween(10_000, 20_000),
Expand Down

0 comments on commit dcf296a

Please sign in to comment.