-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (69 loc) · 2.89 KB
/
github-actions.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
name: Github action of bebenban based on Docker Image CI
on:
push:
branches: ["main", "staging"]
jobs:
deploy:
runs-on: "ubuntu-latest"
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging'
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
########################################
#
# For staging branch
#
########################################
- name: Create S3 directory object if not exists
run: |
BUCKET_NAME=${{ secrets.AWS_BUCKET_NAME_STG }}
DIRECTORY_NAME=${{ vars.AWS_BUCKET_OBJECT_NAME_01 }}
state=`aws s3 ls $BUCKET_NAME/$DIRECTORY_NAME`
if [ -z "$state" ]
then
aws s3api put-object --bucket "$BUCKET_NAME" --key "$DIRECTORY_NAME"
else
echo "Directory already exists"
exit 0
fi
if: ${{ github.ref == 'refs/heads/staging' }}
# Lokalise punya nama yang sama dengan destination dir
- name: Copy json lokalise objects to particular S3 directory
run: |
BUCKET_NAME=${{ secrets.AWS_BUCKET_NAME_STG }}
DIRECTORY_NAME=${{ vars.AWS_BUCKET_OBJECT_NAME_01 }}
LOCAL_DIRECTORY=${{ vars.AWS_BUCKET_OBJECT_NAME_01 }}
aws s3 cp "$LOCAL_DIRECTORY" "$BUCKET_NAME/$DIRECTORY_NAME" --recursive --exclude "*" --include "*.json"
if: ${{ github.ref == 'refs/heads/staging' }}
########################################
#
# For main branch
#
########################################
- name: Create S3 directory object if not exists
run: |
BUCKET_NAME=${{ secrets.AWS_BUCKET_NAME_PROD }}
DIRECTORY_NAME=${{ vars.AWS_BUCKET_OBJECT_NAME_01 }}
state=`aws s3 ls $BUCKET_NAME/$DIRECTORY_NAME`
if [ -z "$state" ]
then
aws s3api put-object --bucket "$BUCKET_NAME" --key "$DIRECTORY_NAME"
else
echo "Directory already exists"
exit 0
fi
if: ${{ github.ref == 'refs/heads/main' }}
# Lokalise punya nama yang sama dengan destination dir
- name: Copy json lokalise objects to particular S3 directory
run: |
BUCKET_NAME=${{ secrets.AWS_BUCKET_NAME_PROD }}
DIRECTORY_NAME=${{ vars.AWS_BUCKET_OBJECT_NAME_01 }}
LOCAL_DIRECTORY="${{ vars.AWS_BUCKET_OBJECT_NAME_01 }}"
aws s3 cp "$LOCAL_DIRECTORY" "$BUCKET_NAME/$DIRECTORY_NAME" --recursive --exclude "*" --include "*.json"
if: ${{ github.ref == 'refs/heads/main' }}