Skip to content

Commit b42e47f

Browse files
committed
add CI/CD workflow and Dockerfile for Stellar Price API
1 parent 688ece6 commit b42e47f

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

.github/workflows/main.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Stellar Price API CI/CD
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.10'
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
25+
pip install pytest pytest-cov flake8
26+
27+
- name: Lint with flake8
28+
run: |
29+
# stop the build if there are Python syntax errors or undefined names
30+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
31+
# exit-zero treats all errors as warnings
32+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
33+
34+
docker:
35+
needs: test
36+
runs-on: ubuntu-latest
37+
if: github.event_name != 'pull_request'
38+
steps:
39+
- uses: actions/checkout@v3
40+
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@v2
43+
44+
- name: Build and export
45+
uses: docker/build-push-action@v4
46+
with:
47+
context: .
48+
file: ./Dockerfile
49+
load: true
50+
tags: stellar-price-api:latest
51+
52+
- name: Test image
53+
run: docker run --rm stellar-price-api:latest python -c "import flask; import stellar_sdk; print('Dependencies loaded successfully')"
54+
55+
deploy:
56+
needs: docker
57+
runs-on: ubuntu-latest
58+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
59+
steps:
60+
- name: Deploy to server
61+
run: echo "Add your deployment steps here"
62+
# Example deployment steps:
63+
# - Install SSH key
64+
# - Connect to server
65+
# - Pull latest code
66+
# - Restart service

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.10-slim
2+
3+
WORKDIR /app
4+
5+
COPY requirements.txt .
6+
RUN pip install --no-cache-dir -r requirements.txt
7+
8+
COPY . .
9+
10+
ENV TOKEN_CODE=OVRL
11+
ENV TOKEN_ISSUER=GBZH36ATUXJZKFRMQTAAW42MWNM34SOA4N6E7DQ62V3G5NVITC3QOVRL
12+
13+
EXPOSE 5000
14+
15+
CMD ["python", "main.py"]

0 commit comments

Comments
 (0)