-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (63 loc) · 2.7 KB
/
s3sync.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
name: SyncToS3-IDrive
# Controls when the action will run.
on:
push:
branches:
- 33
- 32
- 31
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# https://github.com/marketplace/actions/s3-sync
steps:
- uses: actions/checkout@master
- name: Retrieve JSON File
id: json_properties
uses: zoexx/github-action-json-file-properties@release
with:
file_path: "./.github/package.json"
- name: Retrieve S3 JSON File
id: s3_key
uses: zoexx/github-action-json-file-properties@release
with:
file_path: "./.github/s3.json"
- name: Get branch name
id: branch-name
uses: tj-actions/branch-name@v6
- name: Set all variable used
run: |
echo "UPLOAD_FOLDER=${{steps.json_properties.outputs.platform}}/${{steps.json_properties.outputs.product_category}}/${{steps.json_properties.outputs.name}}/${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV
echo "REPO_NAME=${{steps.json_properties.outputs.name}}" >> $GITHUB_ENV
- name: Create folder and removing .git and .github dir
run: |
mkdir ./s3_upload
rsync -a ./ ./s3_upload/$REPO_NAME
rm -rf ./s3_upload/$REPO_NAME/.git*
rm -rf ./s3_upload/$REPO_NAME/s3_upload
- name: Zip the repo and Pack to S3_Upload folder before uploading
uses: vimtor/action-zip@v1
with:
files: ./s3_upload
dest: ./zipped/${{steps.json_properties.outputs.name}}.zip
# Copy the version.xml file to the zipped folder
- name: Copy the version.xml file
run: |
cp -p ./version.xml ./zipped/version.xml
[ -f ./CHANGELOG.md ] && cp -p ./CHANGELOG.md ./zipped/CHANGELOG.md
#everthing is working now, then upload
- name: Upload Zip File to S3 Folder ( Version )
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete --include '*' --exclude './.git/*' --exclude './.github/*' --exclude './.vscode/*' --exclude '.gitignore' --exclude './s3_upload/*' --exclude './.gitmodules'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ steps.s3_key.outputs.region }}
AWS_S3_ENDPOINT: ${{ steps.s3_key.outputs.endpoint }}
AWS_S3_BUCKET: ${{ steps.s3_key.outputs.bucket }}
SOURCE_DIR: "./zipped/"
DEST_DIR: "/$UPLOAD_FOLDER/"