Repository navigation
46 lines (39 loc) · 1.79 KB
/
Copy pathdeploy.yml
File metadata and controls
46 lines (39 loc) · 1.79 KB
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
on:
push:
branches: [master]
env:
AWS_REGION: ap-northeast-2
AWS_DEPLOY_ROLE: ${{ secrets.AWS_DEPLOY_ROLE }}
permissions:
id-token: write
contents: read
jobs:
deploy:
name: deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ env.AWS_DEPLOY_ROLE }}
aws-region: ${{ env.AWS_REGION }}
- name: Build UI and Upload to S3
run: |
sudo apt-get update
sudo apt-get install build-essential libxml2-dev libxmlsec1 libxmlsec1-dev libxmlsec1-openssl musl-dev libcurl4-nss-dev python3-dev pkg-config -y
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash
sudo apt-get install -y nodejs
sudo npm install yarn -g
yarn --cwd ui
yarn --cwd ui build:prod
aws s3 sync ./consoleme/templates/ s3://devops-monthly-report/consoleme/templates/
- name: Sync template from S3 and Restart server
run: |
aws ssm send-command \
--instance-ids "${{ secrets.INSTANCE_ID }}" \
--document-name "AWS-RunShellScript" \
--comment "iam.wanted.jobs" \
--parameters '{"commands":["runuser -l ubuntu -c \"cd /home/ubuntu/consoleme;git pull;pip install -r requirements.txt -r requirements-test.txt -e .;sudo systemctl stop consoleme.service;rm -rf /home/ubuntu/templates/;cp -r /home/ubuntu/consoleme/consoleme/templates/ /home/ubuntu/templates/;aws s3 sync s3://devops-monthly-report/consoleme/templates/ /home/ubuntu/consoleme/consoleme/templates/;python scripts/retrieve_or_decode_configuration.py;sudo systemctl start consoleme.service;\""]}' \
--output text