-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (75 loc) · 3.41 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
name: Deploy to AWS
on:
push:
branches: [main, production]
jobs:
scraper:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ["20.x"]
python-version: ["3.11"]
pipenv-version: ["2024.1.0"]
steps:
# Checkout repository
- uses: actions/checkout@v4
# Environment variables
- name: Set environment variables for staging
if: endsWith(github.ref, '/main')
run: |
echo "STAGE=staging" >> $GITHUB_ENV
echo "NASA_WALDBRANDDATEN_RHODOS_CHART_ID=2zgmZ" >> $GITHUB_ENV
echo "NASA_WALDBRANDDATEN_MAUI_CHART_ID=XNvar" >> $GITHUB_ENV
echo "NASA_WALDBRANDDATEN_TENERIFFA_CHART_ID=Ja0Eq" >> $GITHUB_ENV
- name: Set environment variables for production
if: endsWith(github.ref, '/production')
run: |
echo "STAGE=prod" >> $GITHUB_ENV
echo "NASA_WALDBRANDDATEN_RHODOS_CHART_ID=nru3h" >> $GITHUB_ENV
echo "NASA_WALDBRANDDATEN_MAUI_CHART_ID=folgL" >> $GITHUB_ENV
echo "NASA_WALDBRANDDATEN_TENERIFFA_CHART_ID=Xwt4r" >> $GITHUB_ENV
# Set up Python and install dependencies
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pipenv"
- name: Install pipenv
run: pip install "pipenv==${{ matrix.pipenv-version }}"
- run: pipenv sync --dev
# Set up Serverless for deployment
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install Node.js dependencies
run: npm ci --production
# Additional caching
- name: Cache serverless-python-requirements
id: serverless-python-cache
uses: actions/cache@v4
with:
path: .serverless-python-cache
key: serverless-python-cache-${{ hashFiles('**/pipfile.lock', '**/serverless.part.yml') }}
# Deploy
- name: Generate serverless.yml
run: pipenv run manage generate
- name: Render requirements.txt
run: pipenv requirements > requirements.txt
- name: Deploy with serverless
run: pipenv run npx serverless deploy
env:
STAGE: ${{ env.STAGE }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SWR_BENZINPREISE_SERVICE_ACCOUNT: ${{ secrets.SWR_BENZINPREISE_SERVICE_ACCOUNT }}
# Map key and datawrapper token are shared between staging and production and different scrapers
NASA_WALDBRANDDATEN_RHODOS_MAP_KEY: ${{ secrets.NASA_WALDBRANDDATEN_RHODOS_MAP_KEY }}
NASA_WALDBRANDDATEN_RHODOS_DATAWRAPPER_TOKEN: ${{ secrets.NASA_WALDBRANDDATEN_RHODOS_DATAWRAPPER_TOKEN }}
NASA_WALDBRANDDATEN_RHODOS_CHART_ID: ${{ env.NASA_WALDBRANDDATEN_RHODOS_CHART_ID }}
NASA_WALDBRANDDATEN_MAUI_CHART_ID: ${{ env.NASA_WALDBRANDDATEN_MAUI_CHART_ID }}
NASA_WALDBRANDDATEN_TENERIFFA_DATAWRAPPER_TOKEN: ${{ secrets.NASA_WALDBRANDDATEN_TENERIFFA_DATAWRAPPER_TOKEN }}
NASA_WALDBRANDDATEN_TENERIFFA_CHART_ID: ${{ env.NASA_WALDBRANDDATEN_TENERIFFA_CHART_ID }}
TALSPERREN_DATAWRAPPER_TOKEN: ${{ secrets.NASA_WALDBRANDDATEN_RHODOS_DATAWRAPPER_TOKEN }}