-
Notifications
You must be signed in to change notification settings - Fork 8
171 lines (146 loc) · 6.83 KB
/
run_calculate.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: "Deploy and run calculate"
on:
# This job is triggered only manually (in practice via a github API rest call
# by the otp application) if needed.
# we have to register on push to make the event show up, but it does not actually do anything on push (note "if" conditions below in job)
push:
workflow_dispatch:
env:
PROJECT_NAME: "odh-mentor-otp"
API_HOST: http://localhost
API_PATH: /otp/routers/openmove
API_PORT: 8080
DOCKER_IMAGE_OTP: ghcr.io/${{ github.repository }}/odh-mentor-otp-calculate
DOCKER_TAG: ${{ github.sha }}
jobs:
run-calculate-test:
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch'
concurrency: build-calc-test
steps:
- name: Spin up EC2 instance
run: |
aws ec2 start-instances --instance-ids ${{secrets.AWS_EC2_INSTANCE_ID }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
# this used to be a wait (120 sec) to have the efs volume be mounted. If this makes problems, return to a wait 120
- name: Wait for instance to start up
run: |
aws ec2 wait instance-running --instance-ids ${{secrets.AWS_EC2_INSTANCE_ID }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
- name: Checkout source code
uses: noi-techpark/github-actions/checkout@v2
- name: Create .env file
uses: noi-techpark/github-actions/env-file@v2
env:
X_COMPOSE_PROJECT_NAME: ${{ env.PROJECT_NAME }}
X_DOCKER_IMAGE_OTP: ${{ env.DOCKER_IMAGE_OTP }}
X_DOCKER_TAG: ${{ env.DOCKER_TAG }}
X_EFS_FOLDER: "/opt/odh-mentor-otp-test/"
X_GBFS_HOST : "https://gbfs.otp.opendatahub.testingmachine.eu/"
X_JAVA_MX: "16G"
X_BUILD_GRAPH: "True"
X_DOWNLOAD_DATA: "False"
X_BACKUP_GRAPH: "True"
X_CARSHARING_HOST: "https://carsharing.otp.opendatahub.testingmachine.eu"
X_PARKING_HOST: "https://parking.otp.opendatahub.testingmachine.eu"
X_DRT_HOST: "https://drt.otp.opendatahub.testingmachine.eu"
X_CHARGER_HOST: "https://charger.otp.opendatahub.testingmachine.eu"
X_UPDATERS: "True"
X_GTFS_FILE: "latestGTFS.zip"
X_OTP_OFFICIAL: "False"
X_GBFS_VERSION: 1
X_GTFS_RT_URL: "https://efa.sta.bz.it/gtfs-r/"
X_GTFS_FEED_ID: 1
X_GEOCODER_BASEURL: "https://geocoder.otp.opendatahub.testingmachine.eu"
X_PARKING_BASEURL: "https://parking.otp.opendatahub.testingmachine.eu"
X_DRT_BASEURL: "https://drt.otp.opendatahub.testingmachine.eu"
X_CHARGER_BASEURL: "https://charger.otp.opendatahub.testingmachine.eu"
X_TRAFFIC_BASEURL: "https://traffic.otp.opendatahub.testingmachine.eu"
- name: Deploy / run calculation
uses: noi-techpark/github-actions/docker-deploy@v2
with:
hosts: 'calculate-test'
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
docker-username: 'noi-techpark-bot'
docker-password: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
project-name: ${{ env.PROJECT_NAME }}
playbook-file: deploy.calculate.test.yml
- name: Spin down EC2 instance
run: |
aws ec2 stop-instances --instance-ids ${{secrets.AWS_EC2_INSTANCE_ID }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
run-calculate-prod:
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/prod' && github.event_name == 'workflow_dispatch'
concurrency: build-calc-prod
steps:
- name: Spin up EC2 instance
run: |
aws ec2 start-instances --instance-ids ${{secrets.AWS_EC2_INSTANCE_ID }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
# this used to be a wait (120 sec) to have the efs volume be mounted. If this makes problems, return to a wait 120
- name: Wait for instance to start up
run: |
aws ec2 wait instance-running --instance-ids ${{secrets.AWS_EC2_INSTANCE_ID }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
- name: Checkout source code
uses: noi-techpark/github-actions/checkout@v2
- name: Create .env file
uses: noi-techpark/github-actions/env-file@v2
env:
X_COMPOSE_PROJECT_NAME: ${{ env.PROJECT_NAME }}
X_DOCKER_IMAGE_OTP: ${{ env.DOCKER_IMAGE_OTP }}
X_DOCKER_TAG: ${{ env.DOCKER_TAG }}
X_EFS_FOLDER: "/opt/odh-mentor-otp-prod/"
X_GBFS_HOST : "https://gbfs.otp.opendatahub.com/"
X_JAVA_MX: "16G"
X_BUILD_GRAPH: "True"
X_DOWNLOAD_DATA: "False"
X_BACKUP_GRAPH: "True"
X_CARSHARING_HOST: "https://carsharing.otp.opendatahub.com"
X_PARKING_HOST: "https://parking.otp.opendatahub.com"
X_DRT_HOST: "https://drt.otp.opendatahub.com"
X_CHARGER_HOST: "https://charger.otp.opendatahub.com"
X_UPDATERS: "True"
X_GTFS_FILE: "latestGTFS.zip"
X_OTP_OFFICIAL: "False"
X_GBFS_VERSION: 1
X_GTFS_RT_URL: "https://efa.sta.bz.it/gtfs-r/"
X_GTFS_FEED_ID: 1
X_GEOCODER_BASEURL: "https://geocoder.otp.opendatahub.com"
X_PARKING_BASEURL: "https://parking.otp.opendatahub.com"
X_DRT_BASEURL: "https://drt.otp.opendatahub.com"
X_CHARGER_BASEURL: "https://charger.otp.opendatahub.com"
X_TRAFFIC_BASEURL: "https://traffic.otp.opendatahub.com"
- name: Deploy / run calculation
uses: noi-techpark/github-actions/docker-deploy@v2
with:
hosts: 'calculate-prod'
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
docker-username: 'noi-techpark-bot'
docker-password: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
project-name: ${{ env.PROJECT_NAME }}
playbook-file: deploy.calculate.prod.yml
- name: Spin down EC2 instance
if: always()
run: |
aws ec2 stop-instances --instance-ids ${{secrets.AWS_EC2_INSTANCE_ID }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}