-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (146 loc) · 5.15 KB
/
static.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# Workflow for deploying static content to GitHub Pages, running a racket orchestration suite, and a python application.
name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["production"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages-deploy"
cancel-in-progress: false
jobs:
deploy:
environment:
name: github-pages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3.0.1
with:
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
outputs:
page_url: ${{ steps.deployment.outputs.page_url }}
build-and-test-python:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Set up Python 3.13
uses: actions/setup-python@v5.3.0
with:
python-version: "3.13"
- name: Navigate to directory with main.py and print current directory
run: |
cd ${{ github.workspace }}
pwd
ls -la
- name: Create logs directory
run: mkdir -p logs
- name: Set permissions for logs directory
run: chmod 755 logs
- name: Create setup log file
run: touch logs/setup.log
- name: Create run log file
run: touch logs/python-app.log
- name: Create app log file
run: touch logs/app.log
- name: Create and activate Python virtual environment
run: |
python -m venv venv
source venv/bin/activate
echo $PATH | tee -a logs/setup.log 2>&1
echo $VIRTUAL_ENV | tee -a logs/setup.log 2>&1
echo $PYTHONPATH | tee -a logs/setup.log 2>&1
- name: Install dependencies and set up environment
run: |
sudo apt-get update
sudo apt-get upgrade -y >> logs/setup.log 2>&1
python -m pip install --upgrade pip >> logs/setup.log 2>&1
sudo apt install curl -y
echo "::set-output name=result::success" >> logs/setup.log 2>&1
- name: Run main python app
run: |
source venv/bin/activate
python3 main.py -- python3 ./src/__init__.py 2>&1 | tee -a logs/app.log logs/python-app.log
- name: Archive test output as artifact
if: always()
uses: actions/upload-artifact@v4.6.0
with:
name: python-app
path: logs/python-app.log
validate-repository-state:
needs: [deploy, build-and-test-python]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Set up Racket and jq
run: |
sudo apt-get update
sudo apt-get install -y racket jq
- name: Prepare Racket input data
run: |
mkdir -p logs
cat <<EOF > inputs.json
{
"repository": [
{"id": 1, "branch": "production", "permissions": ["x"], "state": "valid"}
]
}
EOF
- name: Verify `inputs.json` exists
run: |
if [ ! -f inputs.json ]; then
echo "Error: inputs.json does not exist!" >&2
exit 1
fi
- name: Validate `inputs.json` syntax and structure
run: |
jq . inputs.json > /dev/null || { echo "Error: inputs.json is not valid JSON!" >&2; exit 1; }
if ! jq -e '.repository and (.repository | length > 0)' inputs.json > /dev/null; then
echo "Error: inputs.json does not contain a valid 'repository' array!" >&2
exit 1
fi
- name: Format `inputs.json`
run: |
jq . inputs.json > inputs.tmp && mv inputs.tmp inputs.json
- name: Print `inputs.json` content for debugging
run: cat inputs.json
- name: Run Racket script to validate repository state
run: |
racket -t sys.rkt inputs.json > logs/racket-validation.log 2>&1 || {
echo "Racket validation failed. Check logs/racket-validation.log for details." >&2;
cat logs/racket-validation.log;
exit 1;
}
- name: Archive Racket validation output as artifact
if: always()
uses: actions/upload-artifact@v4.6.0
with:
name: racket-validation
path: logs/racket-validation.log
set-environment-url:
needs: [deploy, build-and-test-python, validate-repository-state]
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ needs.deploy.outputs.page_url }}
steps:
- name: No-op step (just to finalize the environment URL)
run: echo "Environment URL set to ${{ needs.deploy.outputs.page_url }}"