-
Notifications
You must be signed in to change notification settings - Fork 1
218 lines (175 loc) · 6.81 KB
/
push.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
name: Build
on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Enable gitlint to check all branch commit messages
- name: Get Python version
run: echo "PYTHON_VERSION=$(cat .python-version)" >> "$GITHUB_ENV"
- name: Use Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip
uses: actions/cache@v4.1.2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ secrets.CACHE_SEED }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('./poetry.lock') }}
restore-keys: ${{ runner.os }}-pip-${{ secrets.CACHE_SEED }}-${{ env.PYTHON_VERSION }}-
- name: Upgrade pip
run: pip install --upgrade pip
- name: Install Poetry
run: pip install poetry
- name: Install Python dependencies
run: poetry install --no-root
- name: Lint and format files
run: poetry run pre-commit run --all-files
- name: Lint commit messages
run: poetry run gitlint --commits=origin/${{ github.base_ref }}..${{ github.event.pull_request.head.sha }} --debug --fail-without-commits
if: ${{ github.event_name == 'pull_request' }}
- name: Coverage
run: poetry run pytest --cov src tests/unit tests/integration
# Deploy to dev on merge to master
deploy-dev:
name: deploy-dev
if: github.ref == 'refs/heads/master'
concurrency:
group: ${{ github.workflow }}
needs: [build]
runs-on: ubuntu-22.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Get Python version
run: echo "PYTHON_VERSION=$(cat .python-version)" >> "$GITHUB_ENV"
- name: Use Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip
uses: actions/cache@v4.1.2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ secrets.CACHE_SEED }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('./poetry.lock') }}
restore-keys: ${{ runner.os }}-pip-${{ secrets.CACHE_SEED }}-${{ env.PYTHON_VERSION }}-
- name: Upgrade pip
run: pip install --upgrade pip
- name: Install Poetry
run: pip install poetry
- name: Install Python dependencies
run: poetry install --no-root
- name: Configure AWS Dev Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-southeast-2
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_DEV }}
- name: Get Node.js version
run: echo "NODE_VERSION=$(cat .nvmrc)" >> "$GITHUB_ENV"
- name: Install Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Node.js packages
uses: actions/cache@v4.1.2
with:
path: ~/.npm
key:
${{ runner.os }}-node-${{ secrets.CACHE_SEED }}-${{ hashFiles('./package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ secrets.CACHE_SEED }}-
- name: install serverless
run: npm install
- name: deploy app
run: npx serverless deploy --stage dev --param=resource-suffix=continuousdeployment
- name: get deployment url
run: echo BASE_URL=$(npx serverless info --stage dev | grep -o 'https.*\/dev\/') >> "$GITHUB_ENV"
- name: Test (sys)
run: BASE_URL=${{ env.BASE_URL }} poetry run pytest tests/sys/
# Deploy to prd on tag
deploy-prd:
name: deploy-prd
if: startsWith(github.ref, 'refs/tags/v')
concurrency:
group: ${{ github.workflow }}
needs: [build]
runs-on: ubuntu-22.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Get Python version
run: echo "PYTHON_VERSION=$(cat .python-version)" >> "$GITHUB_ENV"
- name: Use Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip
uses: actions/cache@v4.1.2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ secrets.CACHE_SEED }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('./poetry.lock') }}
restore-keys: ${{ runner.os }}-pip-${{ secrets.CACHE_SEED }}-${{ env.PYTHON_VERSION }}-
- name: Build project
run: |
echo ${{ github.repository }}
zip -r qgis-plugin-repository.zip .
- name: Create Release
id: create_release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
See [CHANGELOG](https://github.com/linz/qgis-plugin-repository/blob/master/CHANGELOG.md) for detailed release information.
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./qgis-plugin-repository.zip
asset_name: qgis-plugin-repository
asset_content_type: application/zip
- name: Configure AWS Prd Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-southeast-2
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_PRD }}
- name: Get Node.js version
run: echo "NODE_VERSION=$(cat .nvmrc)" >> "$GITHUB_ENV"
- name: Install Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Node.js packages
uses: actions/cache@v4.1.2
with:
path: ~/.npm
key:
${{ runner.os }}-node-${{ secrets.CACHE_SEED }}-${{ hashFiles('./package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ secrets.CACHE_SEED }}-
- name: install serverless
run: npm install
- name: deploy app
run: npx serverless deploy --stage dev --param=resource-suffix=56c159c6dfdsw2378fec41dfd