This repository has been archived by the owner on Feb 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (148 loc) · 5.94 KB
/
main.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
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Task1 QC
on:
push:
branches:
- main
jobs:
process_raw:
runs-on: self-hosted
outputs:
sub: ${{ steps.set_vars.outputs.sub }}
task: ${{ steps.set_vars.outputs.task }}
version: ${{ steps.set_vars.outputs.version }}
steps:
- name: checkout code and return recently uploaded file in /data
uses: actions/checkout@v3
- name: Get changed files
run: |
#!/bin/bash
# Get the list of CSV files changed in the last 24 hours
data=$(git log --since="24 hours ago" --name-only --pretty=format: -- '*.csv' | sort | uniq)
# Export the data variable to the environment
echo "data=$data" >> $GITHUB_ENV
# Print the changed CSV files
echo "Changed CSV files in the last 24 hours: $data"
- name: set up python
run: |
python -m pip install --upgrade pip
- name: parse raw
id: set_vars
run: |
# Loop through each CSV file in $data
for file in $data; do
filename=$(basename "$file")
IFS='_' read -r sub task version <<< "$filename"
version="${version%.csv}" # Remove the .csv extension from version
echo "::set-output name=sub::$sub"
echo "::set-output name=task::$task"
echo "::set-output name=version::$version"
echo "Subject: $sub"
echo "Task: $task"
echo "Version: $version"
done
run_qc:
runs-on: self-hosted
needs: process_raw
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Debug env vars
run: |
echo "sub=${{ needs.process_raw.outputs.sub }}"
echo "task=${{ needs.process_raw.outputs.task }}"
echo "version=${{ needs.process_raw.outputs.version }}"
- name: run quality control
run: |
sub=${{ needs.process_raw.outputs.sub }}
task=${{ needs.process_raw.outputs.task }}
vers=${{ needs.process_raw.outputs.version }}
for sub in ${sub}; do
echo "Processing subject: $sub"
for task in ${task}; do
echo "Processing task: $task"
for vers in ${vers}; do
echo "Processing version: $vers"
csv_file="./data/${sub}/processed/${sub}_${task}_${vers}.csv"
log_file="./data/${sub}/qc_${task}_${vers}.log"
echo "CSV file: $csv_file"
echo "Log file: $log_file"
if [ -f "$csv_file" ]; then
python ./code/AFqC.py -s "$csv_file" -o "./data/${sub}/" -sub "$sub" | tee "$log_file"
echo "QC for ${sub}_${task}_${vers} running"
else
echo "CSV file $csv_file does not exist"
fi
done
done
done
add:
concurrency:
group: "pages"
cancel-in-progress: false
runs-on: self-hosted
needs: run_qc
steps:
- name: find new png files
run: |
png_files=$(git diff --name-only --relative --diff-filter=A -- '*.png')
echo png_files << GITHUB_ENV
- name: Add _posts
run: |
POSTS_DIR="_posts"
# Loop through the images and group by subject number
declare -A subjects
for file in $png_files; do
# Extract the subject number (assuming it's the first part of the filename before '_')
subject=$(echo "$file" | awk -F_ '{print $1}')
# Append the filename to the subject's array
subjects["$subject"]+="$file "
done
# Generate Jekyll posts
for subject in "${!subjects[@]}"; do
# Define the post filename (e.g., using current date and subject number)
post_filename="$POSTS_DIR/$(date +%Y-%m-%d)-subject-$subject.md"
# Create the Jekyll post
echo "---" > "$post_filename"
echo "layout: post" >> "$post_filename"
echo "title: Subject $subject" >> "$post_filename"
echo "date: $(date +%Y-%m-%d)" >> "$post_filename"
echo "categories: subjects" >> "$post_filename"
echo "---" >> "$post_filename"
# Add images to the post
for image in ${subjects["$subject"]}; do
echo "" >> "$post_filename"
done
done
- name: checkout
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@8575951200e472d5f2d95c625da0c7bec8217c42 # v1.161.0
with:
ruby-version: '3.1' # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
cache-version: 0 # Increment this number if you need to re-download cached gems
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Build with Jekyll
# Outputs to the './_site' directory by default
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
env:
JEKYLL_ENV: production
- name: Upload artifact
# Automatically uploads an artifact from the './_site' directory by default
uses: actions/upload-pages-artifact@v3
push:
runs-on: self-hosted
needs: run_qc
steps:
- name: Commit and Push Changes
run: |
git config --global user.name "miloswrath"
git config --global user.email "[email protected]"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git add .
git commit -m "Automated commit by GitHub Actions"
git push
env:
GITHUB_TOKEN: ${{ secrets.GIT_PAT }}