generated from arras-energy/gridlabd-old
-
Notifications
You must be signed in to change notification settings - Fork 5
235 lines (189 loc) · 8.22 KB
/
develop-image.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: develop-images
on:
push:
branches: [ develop ]
jobs:
buildMacos13FastS3:
runs-on: macos-13
environment: Integration
steps:
- uses: actions/checkout@v4
# this is to fix GIT not liking owner of the checkout dir
- name: Set ownership
run: |
chown -R $(id -u):$(id -g) $PWD
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Symlink for libtool
run: |
ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
ln -s /usr/local/bin/glibtool /usr/local/bin/libtool
- name: Add libraries to PATH
run: |
echo "LIBRARY_PATH=$(brew --prefix)/lib:$(brew --prefix)/opt:$(brew --prefix)/include" >> $GITHUB_ENV
- name: Deploy to S3
run: |
sh ./setup.sh --local
sh ./build.sh --system --parallel --upload --release
buildUbuntu22FastS3:
runs-on: ubuntu-24.04
environment: Integration
container:
image: ubuntu:jammy
steps:
# this is to fix GIT not liking owner of the checkout dir
- name: Set ownership and prep container
run: |
mkdir -p /usr/local/var
apt-get update && apt-get install -y apt-transport-https
apt-get install -y git curl nano sudo zip
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
- uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Deploy to S3
run: |
sudo aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY }} && sudo aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} && sudo aws configure set default.region ${{ secrets.AWS_REGION }}
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
chown -R root $PWD
sudo sh ./setup.sh --local
sudo sh ./build.sh --system --parallel
gridlabd python -m pip install awscli
sudo sh ./build.sh --upload --release
buildAWSUbuntuAMI:
runs-on: ubuntu-24.04
environment: Integration
needs: [buildUbuntu22FastS3,buildMacos13FastS3]
steps:
- uses: actions/checkout@v4
# this is to fix GIT not liking owner of the checkout dir
- name: Set ownership
run: |
chown -R $(id -u):$(id -g) $PWD
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Run CF invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.DEV_CF_ID }} --paths '/*'
- name: Set output
run: |
echo "VERSION=Arras Energy HiPAS GridLAB-D $(./build-aux/version.sh --version) (Developer)" >> $GITHUB_ENV
echo "TAGNAME=gridlabd/$(./build-aux/version.sh --version)-$(./build-aux/version.sh --number)-$(./build-aux/version.sh --branch)" >> $GITHUB_ENV
- name: Install Packer
run: |
wget https://releases.hashicorp.com/packer/1.7.6/packer_1.7.6_linux_amd64.zip
unzip packer_1.7.6_linux_amd64.zip
sudo mv packer /usr/local/bin
- name: Initialize Packer
run: |
packer init ./docker/packer/templateDevelop.pkr.hcl
- name: Build AMI Image
run: |
packer build \
-var "aws_access_key=${{ secrets.AWS_ACCESS_KEY }}" \
-var "aws_secret_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}" \
-var "aws_region=${{ secrets.AWS_REGION }}" \
-var "dev_s3_url=${{ secrets.DEV_S3_URL }}" \
-var "version=${{ env.VERSION }}" \
-var "tagname=${{ env.TAGNAME }}" \
./docker/packer/templateDevelop.pkr.hcl
buildUbuntuDockerhub:
runs-on: ubuntu-latest
environment: Integration
needs: buildUbuntu22FastS3
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Run CF invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.DEV_CF_ID }} --paths '/*'
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/packer/Dockerfile.dev.ul
push: true
tags: lfenergy/arras:develop
updateS3websites:
runs-on: ubuntu-latest
environment: Integration
steps:
- uses: actions/checkout@v4
# this is to fix GIT not liking owner of the checkout dir
- name: Set ownership
run: |
chown -R $(id -u):$(id -g) $PWD
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Website s3 sync
run: |
aws s3 sync ./cloud/websites/code.gridlabd.us/ s3://code-dev.gridlabd.us --acl public-read
aws s3 sync ./cloud/websites/docs.gridlabd.us/ s3://docs-dev.gridlabd.us --acl public-read
aws s3 sync ./cloud/websites/geodata.gridlabd.us/ s3://geodata-dev.gridlabd.us --acl public-read
aws s3 sync ./cloud/websites/install.gridlabd.us/ s3://install-dev.gridlabd.us --acl public-read
aws s3 sync ./cloud/websites/status.gridlabd.us/ s3://status-dev.gridlabd.us --acl public-read
aws s3 sync ./cloud/websites/tutorials.gridlabd.us/ s3://tutorials-dev.gridlabd.us --acl public-read
aws s3 sync ./cloud/websites/www.gridlabd.us/ s3://www-dev.gridlabd.us --acl public-read
- name: Run CF invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.DEV_CF_ID }} --paths '/*'
versionUpdate:
runs-on: ubuntu-latest
environment: Integration
needs: buildAWSUbuntuAMI
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Install dependencies and package Lambda function
run: |
pip install -r ./cloud/websites/version.gridlabd.us/lambda/requirements.txt -t ./cloud/websites/version.gridlabd.us/lambda/package
cd ./cloud/websites/version.gridlabd.us/lambda/package
zip -r ../lambda.zip .
cd ..
zip -r lambda.zip app.py
- name: Update Lambda image version_handler
run: |
aws lambda update-function-code --function-name version_handler --zip-file fileb://$(pwd)/cloud/websites/version.gridlabd.us/lambda/lambda.zip
- name: Update Lambda image update_latest
run: |
aws lambda update-function-code --function-name update_latest --zip-file fileb://$(pwd)/cloud/websites/version.gridlabd.us/lambda/lambda.zip
- name: Make POST request to version.gridlabd.us/update
run: |
version=$(./build-aux/version.sh --version)
build=$(./build-aux/version.sh --number)
branch=$(./build-aux/version.sh --branch)
# curl -f -X POST "https://version.gridlabd.us/update_latest" \
# -H "Content-Type: application/json" \
# -d "{\"version\": \"$version\", \"build\": \"$build\", \"branch\": \"$branch\", \"sk\": \"${{ secrets.DEVELOPSK }}\"}"