This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
docs_publish_to_s3.yml
73 lines (66 loc) · 2.09 KB
/
docs_publish_to_s3.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
parameters:
# Whether to build and publish docs.
- name: publishDocs
type: boolean
# Whether to publish docs to S3.
- name: publishDocsS3
type: boolean
steps:
# Install AWS CLI
- script: pip install awscli --upgrade
displayName: 'Install AWS CLI'
condition: |
and(
succeeded(),
${{ parameters.publishDocs }},
${{ parameters.publishDocsS3 }},
eq(variables['Build.SourceBranch'], 'refs/heads/dev')
)
# Sync S3 Contents to latest bucket
- script: |
aws s3 sync \
"./zdocs/build/html" "s3://$(DOCS_S3_BUCKET)/$(REPO_NAME)/latest" \
--delete
env:
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
displayName: 'Upload docs to S3: Latest'
condition: |
and(
succeeded(),
${{ parameters.publishDocs }},
${{ parameters.publishDocsS3 }},
eq(variables['Build.SourceBranch'], 'refs/heads/dev')
)
# Sync S3 Contents to version bucket
- script: |
aws s3 sync \
"s3://$(DOCS_S3_BUCKET)/$(REPO_NAME)/latest" \
"s3://$(DOCS_S3_BUCKET)/$(REPO_NAME)/v$(RELEASE_VERSION)"
env:
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
displayName: 'Sync S3 latest -> version'
condition: |
and(
succeeded(),
${{ parameters.publishDocs }},
${{ parameters.publishDocsS3 }},
eq(variables['Build.SourceBranch'], 'refs/heads/dev')
)
# Invalidate Content Cache For Latest
- script: |
aws cloudfront create-invalidation \
--distribution-id $(DOCS_CLOUDFORMATION_DISTRO_ID) \
--paths "/$(REPO_NAME)/latest/*"
env:
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
displayName: 'Invalidate CloudFront Cache'
condition: |
and(
succeeded(),
${{ parameters.publishDocs }},
${{ parameters.publishDocsS3 }},
eq(variables['Build.SourceBranch'], 'refs/heads/dev')
)