forked from binary-com/deriv-com
-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (126 loc) · 5.71 KB
/
content.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Release Academy Content
on:
repository_dispatch:
types: [publish_academy]
env:
GATSBY_CPU_COUNT: 2
GATSBY_ENV: production
DIRECTUS_AUTH_TOKEN: ${{ secrets.DIRECTUS_AUTH_TOKEN }}
GATSBY_ENV_CIO_SITE_ID: ${{ secrets.GATSBY_ENV_CIO_SITE_ID }}
jobs:
lint:
timeout-minutes: 10
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout 🛎️
uses: actions/[email protected]
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- name: Cache dependencies
id: cache
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- name: Install Node.js dependencies
run: |
npm ci
npm test
release-production:
needs: lint
timeout-minutes: 30
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout 🛎️
uses: actions/[email protected]
- name: fetch git tags
id: get_tag_name
run: |
git fetch --prune --unshallow --tags
GIT_TAG_NAME=`git tag --format='%(creatordate:short)%09%(refname:strip=2)' --sort=creatordate | grep production | awk '{ print $2; }' | tail -1`
echo "git tag is ${GIT_TAG_NAME}"
echo ::set-output name=VERSION::${GIT_TAG_NAME}
- name: Clone latest production tag
uses: actions/[email protected]
with:
ref: ${{ steps.get_tag_name.outputs.VERSION }}
- name: Setup Node
uses: actions/[email protected]
with:
node-version: '14.x'
- name: Set version env variable
run: echo "GATSBY_DERIV_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Cache Gatsby
id: gatsby-cache-build
uses: actions/cache@v2
with:
path: |
public
.cache
key: ${{ runner.os }}-gatsby-build-${{ secrets.CACHE_VERSION }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-gatsby-build-${{ secrets.CACHE_VERSION }}
- run: npm ci
- run: npm run format
- run: npm run test
- run: npm run build
- name: Remove Storybook
uses: JesseTG/[email protected]
with:
path: public/storybook
- uses: olegtarasov/[email protected]
id: tagName
# For using same tag for staging and production we need to uncomment these two below lines:
# with:
# tagRegex: "production(.*)"
- name: Building docker image 🐳
run: docker build -t ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:latest -t ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:${{ steps.get_tag_name.outputs.VERSION }} .
- name: Pushing Image to docker hub 🐳
run: |
echo ${{ secrets.DOCKERHUB_PASSWORD }}| docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker push ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:latest
docker push ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:${{ steps.get_tag_name.outputs.VERSION }}
- name: git tag used for deployment
run: |
echo "git tag used for deployment is: ${{ steps.get_tag_name.outputs.VERSION }} "
- name: Deploy 🚀
run: |
export NAMESPACE="deriv-com-production"
export SERVICEACCOUNT_TOKEN=${{ secrets.SERVICEACCOUNT_TOKEN }}
export DOCKERHUB_ORGANISATION=${{ secrets.DOCKERHUB_ORGANISATION }}
export KUBE_SERVER=${{ secrets.KUBE_SERVER }}
export CA=${{ secrets.CA }}
git clone https://github.com/binary-com/devops-ci-scripts
cd devops-ci-scripts/k8s-build_tools
echo ${{ secrets.CA_CRT}} | base64 --decode > ca.crt
./release.sh deriv-com ${{ steps.get_tag_name.outputs.VERSION }}
- name: Deploy to Cloudflare ☁️
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages publish public --project-name=deriv-com-pages --branch=main
- name: Cloudflare production link ✨
run: echo "New website - http://cf-pages-deriv-com.deriv.com"
- name: Slack Notification 📣
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: workflow,repo
if_mention: failure,cancelled
custom_payload: |
{
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `Release for *Deriv.com* with version *${{ steps.get_tag_name.outputs.VERSION }}*`
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: always()