-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (49 loc) · 1.99 KB
/
deploy.yaml
File metadata and controls
62 lines (49 loc) · 1.99 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
name: Prod Env Latest Build and Deploy to S3
on:
push:
branches:
- main
paths-ignore:
- 'README.md'
- 'Release.md'
- '.github/**'
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Nix
uses: cachix/install-nix-action@v16
- name: Build Archive
id: build_archive
run: |
make archive
if [ ! -f "wire-docs.tar.gz" ]; then
echo "Artifact not found!"
exit 1
fi
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: eu-west-1
- name: Deploy latest docs to S3
run: |
mkdir -p tmp_extracted
tar -xzf ./wire-docs.tar.gz -C tmp_extracted
# fetching upstream versions to retain information on already existing versions
aws s3 cp s3://${{ secrets.BUCKET }}/versions.json tmp_extracted/upstream_versions.json
# merge the both versions.json files and keep the unique entries while giving priority to current versions.json
jq -s '.[0] + .[1] | unique_by(.version + .title)' tmp_extracted/versions.json tmp_extracted/upstream_versions.json > tmp_extracted/all_versions.json
# removing old objects from the bucket to ensure, we don't keep objects at old path
aws s3 rm s3://${{ secrets.BUCKET }}/latest --recursive
# pushing all the latest build documents
aws s3 sync tmp_extracted/latest s3://${{ secrets.BUCKET }}/latest
# syncing the index.html file
aws s3 cp tmp_extracted/index.html s3://${{ secrets.BUCKET }}/index.html
# syncying the all_versions.json with versions.json
aws s3 cp tmp_extracted/all_versions.json s3://${{ secrets.BUCKET }}/versions.json
rm -rf tmp_extracted