File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Submit answer and check puzzle resolution
2+
3+ on :
4+ pull_request :
5+ paths :
6+ - ' puzzles/**/*.py'
7+ types :
8+ - opened
9+
10+ jobs :
11+ get-answer :
12+ runs-on : ubuntu-latest
13+ steps :
14+ - name : Checkout
15+ uses : actions/checkout@v4
16+
17+ - name : Set up Python
18+ uses : actions/setup-python@v5
19+ with :
20+ python-version : ' 3.x'
21+
22+ - name : Extract year and day from branch name
23+ id : extract
24+ run : |
25+ branch_name=$(echo "${{ github.event.pull_request.head.ref }}")
26+
27+ if [[ $branch_name =~ puzzle/([0-9]{4})-day-([1-9]|1[0-9]|2[0-5]) ]]; then
28+ year="${BASH_REMATCH[1]}"
29+ day="${BASH_REMATCH[2]}"
30+
31+ echo "year=${year}" >> $GITHUB_OUTPUT
32+ echo "day=${day}" >> $GITHUB_OUTPUT
33+ else
34+ echo "Branch name does not follow the expected pattern."
35+ exit 1
36+ - name : Get answer
37+ id : get_answer
38+ run : |
39+ year="${{ steps.extract.outputs.year }}"
40+ day="${{ steps.extract.outputs.day }}"
41+
42+ script_path="puzzles/$year/day $day/resolution.py"
43+
44+ if [ -f "$script_path" ]; then
45+ echo "Running script: $script_path"
46+ answer=$(python $script_path)
47+ echo "Answer: $answer"
48+ echo "answer=${answer}" >> $GITHUB_OUTPUT
49+ else
50+ echo "Script not found: $script_path"
51+ exit 1
52+ - name : Submit answer
53+ id : submit_answer
54+ run : |
55+ echo "Result: ${{ steps.get_answer.outputs.answer }}"
56+ exit 1
You can’t perform that action at this time.
0 commit comments