-
Notifications
You must be signed in to change notification settings - Fork 4
126 lines (112 loc) · 3.39 KB
/
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
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
name: Deploy App
on:
push:
branches:
- develop
- main
- 'feature/**'
tags:
- v**
permissions:
id-token: write
contents: write
checks: write
issues: read
packages: read
pull-requests: write
jobs:
detectenv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Detecting environment
id: get_env
run: |
echo "Running on ${{ github.ref }}"
echo "env_isFeature=false" >> $GITHUB_OUTPUT
if [ "${{ github.ref_type }}" = "tag" ]; then
echo "env_name=production" >> $GITHUB_OUTPUT
echo "env_suffix=p" >> $GITHUB_OUTPUT
elif [ "${{ github.ref }}" = "refs/heads/main" ]; then
echo "env_name=production" >> $GITHUB_OUTPUT
echo "env_suffix=p" >> $GITHUB_OUTPUT
elif [ "${{ github.ref }}" = "refs/heads/develop" ]; then
echo "env_name=development" >> $GITHUB_OUTPUT
echo "env_suffix=d" >> $GITHUB_OUTPUT
else
echo "env_name=development" >> $GITHUB_OUTPUT
echo "env_suffix=d" >> $GITHUB_OUTPUT
echo "env_isFeature=true" >> $GITHUB_OUTPUT
fi
outputs:
env_name: ${{ steps.get_env.outputs.env_name }}
env_suffix: ${{ steps.get_env.outputs.env_suffix }}
env_isFeature: ${{ steps.get_env.outputs.env_isFeature }}
snyk:
needs: [detectenv]
runs-on: ubuntu-latest
environment:
name: ${{ needs.detectenv.outputs.env_name }}
steps:
- uses: actions/checkout@v4
- uses: snyk/actions/setup@master
- name: Setup python
uses: actions/setup-python@v4
with:
python-version-file: 'pyproject.toml'
cache: 'pip'
- name: Pip install
run: |
pip install --upgrade pip
pip install -e .
poetry install
- name: Run snyk tests
run: |
snyk auth ${{ secrets.SNYK_TOKEN }}
snyk test --all-projects --severity-threshold=high
snyk code test --all-projects --severity-threshold=high
if [ "${{ needs.detectenv.outputs.env_isFeature }}" = "false" ]; then
snyk monitor --all-projects --severity-threshold=high --project-tags=application=TIMESERIESSDK
fi
run-tests:
name: Run tests
needs: [detectenv, snyk]
runs-on: ubuntu-latest
environment:
name: ${{ needs.detectenv.outputs.env_name }}
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
with:
python-version-file: 'pyproject.toml'
cache: 'pip'
- name: Run tests
run: |
pip install --upgrade pip
pip install -e .
python -m pytest
build:
needs: [detectenv, run-tests]
runs-on: ubuntu-latest
if: startsWith(github.ref_type, 'tag')
environment:
name: ${{ needs.detectenv.outputs.env_name }}
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
with:
python-version-file: 'pyproject.toml'
cache: 'pip'
- name: Build SDK
run: |
pip install --upgrade pip
pip install -e .
python -m build
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: ./dist/*
generateReleaseNotes: true
allowUpdates: true