-
Notifications
You must be signed in to change notification settings - Fork 242
124 lines (105 loc) · 3.72 KB
/
ci-build-upload.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: "Build and upload helps"
on:
create:
push:
jobs:
build-apps:
name: "Build Apps"
runs-on: ubuntu-latest
outputs:
help_modified: ${{steps.changes.outputs.help_modified}}
steps:
- name: Checkout Web-Apps
uses: actions/checkout@v3
with:
repository: onlyoffice/web-apps
ref: ${{github.ref}}
path: 'web-apps'
- name: Path filter for help
if: (startsWith(github.ref, 'refs/heads/release/') ||
startsWith(github.ref, 'refs/heads/hotfix/'))
uses: dorny/paths-filter@v2
id: changes
with:
working-directory: 'web-apps'
base: ${{github.ref}}
initial-fetch-depth: '1'
filters: |
help_modified:
- added|deleted|modified: '**/resources/help/**'
- name: Determine branch variable
run: |
if ${{steps.changes.outputs.help_modified == 'true'}}; then
echo "REF=${{ github.ref }}" >> $GITHUB_ENV
else
echo "REF=develop" >> $GITHUB_ENV
fi
- name: Checkout SDKJS
uses: actions/checkout@v3
with:
repository: onlyoffice/sdkjs
token: ${{ secrets.READ_PAT }}
ref: ${{env.REF}}
path: 'sdkjs'
fetch-depth: '1'
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Build
run: |
cd web-apps/build
./sprites.sh
npm install
grunt
- name: Apps files
id: apps-files
if: steps.changes.outputs.help_modified == 'true'
run: tar -cvf apps.tar ./web-apps/deploy/web-apps/apps
- name: Upload artifact
if: steps.apps-files.outcome == 'success'
uses: actions/upload-artifact@v3
with:
name: apps-artifact
path: apps.tar
upload-apps:
name: "Upload on S3"
runs-on: ubuntu-latest
needs: build-apps
if: needs.build-apps.outputs.help_modified == 'true'
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: apps-artifact
- name: Extract files
run: |
tar -xvf apps.tar
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}}
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}}
aws-region: us-east-1
- name: Export tag and directory path
id: tag-dir
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
export TAG=${BRANCH_NAME#*/}
echo "URI=/install/desktop/editors/help/$TAG/apps" >> $GITHUB_OUTPUT
- name: Upload
env:
URI: ${{steps.tag-dir.outputs.URI}}
run: |
aws s3 sync ./web-apps/deploy/web-apps/apps/ \
${{secrets.AWS_BUCKET_URL}}${URI} \
--acl public-read \
--metadata-directive REPLACE
- name: Invalidate AWS CLOUDFRONT cache
env:
URI: ${{steps.tag-dir.outputs.URI}}
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.AWS_DISTRIBUTION_ID }} \
--paths \
"${URI}/*"