-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
58 lines (52 loc) · 1.28 KB
/
.gitlab-ci.yml
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
stages:
- build
- test
- deploy
- destroy
variables:
NODE_VERSION: 18-alpine3.20
AWS_DEFAULT_REGION: eu-west-3 # Adaptez selon votre région
TERRAFORM_VERSION: 1.10.1
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- .next/cache/
build:
stage: build
image: node:${NODE_VERSION}
script:
- npm ci
- npm run build
- npm run export
artifacts:
paths:
- out/
expire_in: 1 week
deploy_s3_cloudfront:
stage: deploy
image:
name: hashicorp/terraform:${TERRAFORM_VERSION}
entrypoint: [""]
script:
- terraform init
- terraform apply -auto-approve
- export CLOUDFRONT_DISTRIBUTION_ID=$(terraform output -raw cloudfront_distribution_id)
#- echo "Distribution ID: $CLOUDFRONT_DISTRIBUTION_ID"
- apk add aws-cli
- aws s3 sync out/ s3://${S3_BUCKET_NAME} --delete
#- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/index.html"
only:
- main # Déploiement uniquement sur la branche mainnnn
destroy_infrastructure:
stage: destroy
image:
name: hashicorp/terraform:${TERRAFORM_VERSION}
entrypoint: [""]
script:
- terraform init
- terraform plan
- terraform destroy -auto-approve
when: manual # Déclenché manuellement!
only:
- main