-
Notifications
You must be signed in to change notification settings - Fork 2
66 lines (57 loc) · 2.13 KB
/
build-deploy.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
name: CI/CD
on:
release:
types: [published]
jobs:
prepare-targets:
outputs:
targets: ${{ steps.tag-test.outputs.targets }}
target-count: ${{ steps.tag-test.outputs.target-count }}
runs-on: ubuntu-latest
steps:
- id: tag-test
name: Test whether/where to build & deploy tag
shell: python
run: |
import json
import re
TARGET_PATTERNS = (
('staging', r'^\d+\.\d+.*$'),
('production', r'^\d+\.\d+\.\d+$'),
)
targets = [
target for (target, pattern) in TARGET_PATTERNS
if re.search(pattern, '${{ github.event.release.tag_name }}')
]
print('::set-output name=targets::' + json.dumps(targets))
print('::set-output name=target-count::' + json.dumps(len(targets)))
build-deploy:
needs: prepare-targets
runs-on: ubuntu-latest
if: fromJson(needs.prepare-targets.outputs.target-count) > 0
strategy:
matrix:
target: ${{ fromJson(needs.prepare-targets.outputs.targets) }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install management dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirement/console.txt
- name: Build, push & deploy
run: manage --show build ${{ matrix.target }} --label=${{ github.event.release.tag_name }} --if-latest --login --push --deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
ECS_CLUSTER_NAME: ${{ secrets.ECS_CLUSTER_NAME }}
ECS_SERVICE_NAME: ${{ secrets.ECS_SERVICE_NAME }}
GITHUB_AUTH: ${{ github.token }}
GITHUB_REPO: ${{ github.repository }}
IMAGE_REPOSITORY_NAME: ${{ secrets.IMAGE_REPOSITORY_NAME }}
IMAGE_REPOSITORY_URI: ${{ secrets.IMAGE_REPOSITORY_URI }}