-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (63 loc) · 2.22 KB
/
ci.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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Python unit Tests
run: |
echo "Running tests..."
python web/Bases\ web/jsons/_test_compras_automatico.py
python web/Bases\ web/jsons/_test_convenio_automatico.py
python web/Bases\ web/jsons/_test_credito_automatico.py
python web/Bases\ web/jsons/_test_licitacoes_automatico.py
python web/Bases\ web/jsons/_test_verbas_automatico.py
# The workflow will fail automatically if any test fails
# Any output from test failures will be visible in the logs
- name: Build and Run HTTP server and verify
run: |
python -m http.server 8000 &
# Give the server time to start
for i in {1..10}; do
if curl -s http://localhost:8000/index.html > /dev/null; then
echo "Server is up and running."
break
else
echo "Waiting for server to start..."
sleep 1
fi
done
# Fetch the page
curl -I http://localhost:8000/index.html
- name: Set up Git for deployment
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
- name: Fetch and Checkout Branch
run: |
git fetch origin
git checkout projeto_deploy || git checkout -b projeto_deploy
git pull origin projeto_deploy || echo "Failed to pull from projeto_deploy."
- name: Commit and Push Changes
run: |
git add .
git commit -m "Deploy changes to projeto_deploy branch" || echo "No changes to commit"
git push origin projeto_deploy || echo "Failed to push changes to projeto_deploy."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}