-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (53 loc) · 1.98 KB
/
cd-prod-botnorrea-v2-telegram.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
name: cd-dev-botnorrea-v2-telegram
on:
push:
branches: [master]
jobs:
unit-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ["18.x"]
steps:
- uses: actions/checkout@v3
# Obtener el nombre del autor del commit
- name: Get commit author
run: |
author=$(git log -1 --format='%an')
echo "author=$author"
# Create new git tag
- name: Create new git tag
if: ${{ author != '${{ secrets.BOTNORREA_V2_NAME }}' }}
run: |
git config --global user.email "${{ secrets.BOTNORREA_V2_EMAIL }}"
git config --global user.name "${{ secrets.BOTNORREA_V2_NAME }}"
git tag -a "v$(npm run version)" -m "Deploy by ${{ secrets.BOTNORREA_V2_NAME }}"
git push origin master "v$(npm run version)"
# Deploy to production
- name: Using Node.js ${{ matrix.node-version }}
if: ${{ author == '${{ secrets.BOTNORREA_V2_NAME }}' }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
if: ${{ author == '${{ secrets.BOTNORREA_V2_NAME }}' }}
run: |
npm install -g serverless
npm i
- name: Create JSON
if: ${{ author == '${{ secrets.BOTNORREA_V2_NAME }}' }}
id: create-json
uses: jsdaniell/[email protected]
with:
name: "dev.json"
json: ${{ secrets.CONFIG_FILE_PROD }}
dir: "config/"
- name: Setup credentials
if: ${{ author == '${{ secrets.BOTNORREA_V2_NAME }}' }}
run: serverless config credentials --provider aws --key ${{ secrets.KEY_ID }} --secret ${{ secrets.SECRET_ACCESS_KEY }} --profile ${{ secrets.PROFILE }}
- name: Deploy
if: ${{ author == '${{ secrets.BOTNORREA_V2_NAME }}' }}
run: npm run prod:deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SECRET_ACCESS_KEY }}