File tree Expand file tree Collapse file tree 2 files changed +61
-14
lines changed
Expand file tree Collapse file tree 2 files changed +61
-14
lines changed Original file line number Diff line number Diff line change 1- name : Auto open pull request on challenge branches
1+ name : Auto open pull request on puzzle branches
22
33on :
44 push :
55 branches :
6- - ' challenge/201[5-9]-day-1[0-9]'
7- - ' challenge/201[5-9]-day-2[0-5]'
8- - ' challenge/201[5-9]-day-[1-9]'
9- - ' challenge/20[2-9][0-9]-day-1[0-9]'
10- - ' challenge/20[2-9][0-9]-day-2[0-5]'
11- - ' challenge/20[2-9][0-9]-day-[1-9]'
12- - ' challenge/2[1-9][0-9][0-9]-day-1[0-9]'
13- - ' challenge/2[1-9][0-9][0-9]-day-2[0-5]'
14- - ' challenge/2[1-9][0-9][0-9]-day-[1-9]'
15- - ' challenge/[3-9][0-9][0-9][0-9]-day-1[0-9]'
16- - ' challenge/[3-9][0-9][0-9][0-9]-day-2[0-5]'
17- - ' challenge/[3-9][0-9][0-9][0-9]-day-[1-9]'
6+ - ' puzzle/**'
187
198jobs :
209 open-pull-request :
2312 - name : get issue number
2413 id : get_issue_number
2514 run : |
26- if [[ ${{ github.ref_name }} =~ challenge /([0-9]{4})-day-([1-9]|1[0-9]|2[0-5]) ]]; then
15+ if [[ ${{ github.ref_name }} =~ puzzle /([0-9]{4})-day-([1-9]|1[0-9]|2[0-5]) ]]; then
2716 year=${BASH_REMATCH[1]}
2817 day=${BASH_REMATCH[2]}
2918
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+
37+ - name : Get answer
38+ id : get_answer
39+ run : |
40+ year="${{ steps.extract.outputs.year }}"
41+ day="${{ steps.extract.outputs.day }}"
42+
43+ script_path="puzzles/$year/day $day/resolution.py"
44+
45+ if [ -f "$script_path" ]; then
46+ echo "Running script: $script_path"
47+ answer=$(python $script_path)
48+ echo "Answer: $answer"
49+ echo "answer=${answer}" >> $GITHUB_OUTPUT
50+ else
51+ echo "Script not found: $script_path"
52+ exit 1
53+
54+ - name : Submit answer
55+ id : submit_answer
56+ run : |
57+ echo "Result: ${{ steps.get_answer.outputs.answer }}"
58+ exit 1
You can’t perform that action at this time.
0 commit comments