This repository was archived by the owner on May 20, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 48
129 lines (113 loc) · 4.58 KB
/
Copy pathprod.yml
File metadata and controls
129 lines (113 loc) · 4.58 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
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
name: Prod
on:
push:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.6
env:
MYSQL_ROOT_PASSWORD: "changeme123"
MYSQL_DATABASE: "standard_notes_db"
MYSQL_USER: "std_notes_user"
MYSQL_PASSWORD: "changeme123"
ports:
- 3306:3306
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.5
- name: Copy default configuration
run: cp .env.sample .env
- name: Install dependencies
run: bundle install
- name: Setup database
run: bundle exec rails db:create db:migrate
- name: Run tests
run: bundle exec rspec
publish:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Docker buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Publish to Registry
run: |
docker buildx build --push \
--tag standardnotes/syncing-server:latest \
--tag standardnotes/syncing-server:${{ github.sha }} \
--platform linux/amd64,linux/arm64 .
deploy-web:
needs: publish
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Download task definition
run: |
aws ecs describe-task-definition --task-definition syncing-server-prod --query taskDefinition > task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: syncing-server-prod
image: "standardnotes/syncing-server:${{ github.sha }}"
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: syncing-server-prod
cluster: prod
wait-for-service-stability: true
deploy-worker:
needs: publish
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Download task definition
run: |
aws ecs describe-task-definition --task-definition syncing-server-worker-prod --query taskDefinition > worker-task-definition.json
- name: Fill in the new image worker ID in the Amazon ECS task definition
id: worker-task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: worker-task-definition.json
container-name: syncing-server-worker-prod
image: "standardnotes/syncing-server:${{ github.sha }}"
- name: Deploy Amazon ECS worker task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.worker-task-def.outputs.task-definition }}
service: syncing-server-worker-prod
cluster: prod
wait-for-service-stability: true
notify_slack:
needs: [ deploy-worker, deploy-web ]
runs-on: ubuntu-latest
steps:
- name: Notify slack
uses: pullreminders/slack-action@master
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
args: '{ \"channel\": \"${{ secrets.SLACK_NOTIFICATION_CHANNEL }}\", \"blocks\": [{\"type\": \"section\", \"text\": {\"type\": \"mrkdwn\", \"text\": \"Successfully deployed <https://syncing-server-prod.standardnotes.org|[PROD] Syncing Server>\"}}, {\"type\": \"section\", \"text\": {\"type\": \"mrkdwn\", \"text\": \"Changes: <https://github.com/standardnotes/syncing-server/commit/${{ github.sha }}|${{ github.sha }}>\"}, \"accessory\": {\"type\": \"image\", \"image_url\": \"https://website-dev.standardnotes.org/assets/icon.png\", \"alt_text\": \"Standard Notes\"}}, { \"type\": \"section\", \"fields\": [{\"type\": \"mrkdwn\", \"text\": \"<https://github.com/standardnotes/syncing-server/actions/runs/${{ github.run_id }}|Build details>\"}]}]}'