forked from 100-hours-a-week/10-wingterview-fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
76 lines (69 loc) ยท 1.67 KB
/
Jenkinsfile
File metadata and controls
76 lines (69 loc) ยท 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
pipeline {
agent any
triggers {
githubPush()
}
environment {
AWS_REGION = 'ap-northeast-2'
S3_BUCKET = 'winterview-dev'
CLOUDFRONT_DIST_ID = 'E2P5DOV93GKL9D'
}
stages {
stage('Checkout Code') {
steps {
git branch: 'dev', url: 'https://github.com/100-hours-a-week/10-team-matching-quiz-fe.git'
}
}
stage('Prepare Env File') {
steps {
withCredentials([file(credentialsId: 'env-dev', variable: 'ENV_FILE')]) {
sh '''
echo ".env ํ์ผ ๋ณต์ฌ ์ค"
cp $ENV_FILE .env
'''
}
}
}
stage('Install & Build') {
steps {
sh '''
npm install
npm run build
'''
}
}
stage('Upload to S3') {
steps {
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: 'aws-cred',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
]]) {
sh '''
aws s3 sync ./dist s3://$S3_BUCKET \
--region $AWS_REGION \
--cache-control "no-cache" \
--delete
'''
}
}
}
stage('Invalidate CloudFront') {
steps {
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: 'aws-cred',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
]]) {
sh '''
aws cloudfront create-invalidation \
--distribution-id $CLOUDFRONT_DIST_ID \
--paths "/*"
'''
}
}
}
}
}