Skip to content

Commit

Permalink
fix aws deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
GaspardRivoire committed Jul 3, 2024
1 parent 5fb6e09 commit 4e7a2ec
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions src/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,8 @@ async function archivePage(dirPath: string, page: Page, ressources: Record<strin
*/
export async function archiveWebsite() {
logger.infoBold('======= Archiving 1Village =======');

logger.info(`==> YEAR : ${process.env.YEAR ?? ''}`);
logger.info(`==> ADMIN_USERNAME : ${process.env.ADMIN_USERNAME ?? ''}`);
logger.info(`==> URL_TO_ARCHIVE : ${process.env.URL_TO_ARCHIVE ?? ''}`);


let resources: Record<string, string> = {};
try {
Expand Down
7 changes: 4 additions & 3 deletions src/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import path from 'path';
import { logger } from './logger';

const s3Client = new S3Client({
region: 'eu-west-3',
credentials: {
accessKeyId: process.env.S3_ACCESS_KEY ?? '',
secretAccessKey: process.env.S3_SECRET_KEY ?? '',
Expand All @@ -22,7 +23,7 @@ const s3Client = new S3Client({
*/
async function uploadS3File(filepath: string, file: Buffer | fs.ReadStream, contentType: string): Promise<void> {
const command = new PutObjectCommand({
Bucket: process.env.S3_BUCKET_NAME,
Bucket: `${process.env.S3_BUCKET_NAME ?? ''}`,
Key: filepath,
Body: file,
ContentType: contentType,
Expand Down Expand Up @@ -55,6 +56,6 @@ export async function upload(dirPath: string) {
logger.startLoading(`Uploading archive to S3, to access it from the browser!`);
await uploadDir(dirPath);
logger.stopLoading();
const url = process.env.USE_MINIO ? `http://localhost:5000/api` : `${process.env.URL_TO_ARCHIVE}/api`;
logger.success(`Archive uploaded! Available at: ${url}${dirPath.slice(12)}`);
const url = `${process.env.URL_TO_ARCHIVE}/archives/${dirPath.split('/').pop()}`;
logger.success(`Archive uploaded! Available at: ${url}`);
}
1 change: 0 additions & 1 deletion src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ async function main() {
logger.infoBold('======= Deploying new Archive =======');
logger.info(`==> YEAR : ${process.env.YEAR ?? ''}`);
logger.info(`==> S3_BUCKET_NAME : ${process.env.S3_BUCKET_NAME ?? ''}`);

const year = process.env.YEAR ?? '';
const dirPath = `archive/api/archives/${year.replace(/\//gim, '-')}`;
await upload(dirPath);
Expand Down
2 changes: 1 addition & 1 deletion src/village.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function getVillageCount(page: Page): Promise<number> {
return count;
} catch (e) {
// logger.stopLoading();
logger.error(e);
logger.info(e);
return 0;
}
}
Expand Down

0 comments on commit 4e7a2ec

Please sign in to comment.