diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index a01e667..2d2d68f 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -9,14 +9,17 @@ jobs: open-pull-request: runs-on: ubuntu-latest steps: - - name: get issue number + - name: Checkout + uses: actions/checkout@v4 + + - name: Get issue number id: get_issue_number run: | if [[ ${{ github.ref_name }} =~ puzzle/([0-9]{4})-day-([1-9]|1[0-9]|2[0-5]) ]]; then year=${BASH_REMATCH[1]} day=${BASH_REMATCH[2]} - issue_number=$(gh issue list -S '[$year] [Day $day] in:title' --json number | jq '.[].number') + issue_number=$(gh issue list -S "[$year] [Day $day] in:title" --json number | jq '.[].number') if [ -z "$issue_number" ]; then echo "::error::Issue not found!" @@ -30,7 +33,8 @@ jobs: fi env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} - - name: create pull request - run: gh pr create -B ${{ GITHUB_DEFAULT_BRANCH }} -H ${{ github.ref_name }} --title 'Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}' + - name: Create pull request + run: | + gh pr create -B main -H ${{ github.ref_name }} -t "Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}" -b "" env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} diff --git a/.github/workflows/check-resolution.yml b/.github/workflows/check-resolution.yml index 91f03b3..3f4d8a6 100644 --- a/.github/workflows/check-resolution.yml +++ b/.github/workflows/check-resolution.yml @@ -33,6 +33,7 @@ jobs: else echo "Branch name does not follow the expected pattern." exit 1 + fi - name: Get answer id: get_answer @@ -40,7 +41,7 @@ jobs: year="${{ steps.extract.outputs.year }}" day="${{ steps.extract.outputs.day }}" - script_path="puzzles/$year/day $day/resolution.py" + script_path="puzzles/$year/day-$day/resolution.py" if [ -f "$script_path" ]; then echo "Running script: $script_path" @@ -50,6 +51,7 @@ jobs: else echo "Script not found: $script_path" exit 1 + fi - name: Submit answer id: submit_answer diff --git a/.github/workflows/update-issue.yml b/.github/workflows/update-issue.yml index cf7d0ec..4b050bc 100644 --- a/.github/workflows/update-issue.yml +++ b/.github/workflows/update-issue.yml @@ -12,20 +12,24 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Parsing issue id: issue-parser uses: stefanbuck/github-issue-parser@v3 with: template-path: .github/ISSUE_TEMPLATE/puzzle.yml + - name: Adding milestone to issue uses: Julexar/Milestone-Assigner@v1.0 with: token: "${{ secrets.ACTION_TOKEN }}" milestone: "${{ steps.issue-parser.outputs.issueparser_puzzle-year }} Puzzles" + - name: Run bash script to extract day from issue title id: extract run: | title="${{ github.event.issue.title }}" + if [[ $title =~ Day\ ([0-9]+) ]]; then day=${BASH_REMATCH[1]} echo "day=${day}" >> $GITHUB_OUTPUT @@ -33,6 +37,7 @@ jobs: echo "::error::Title does not match the expected pattern" exit 1 fi + - name: Create comment uses: peter-evans/create-or-update-comment@v4 with: diff --git a/puzzles/2015/day 1/.keep b/puzzles/2015/day 1/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/puzzles/2015/day-1/resolution.py b/puzzles/2015/day-1/resolution.py new file mode 100644 index 0000000..5062962 --- /dev/null +++ b/puzzles/2015/day-1/resolution.py @@ -0,0 +1,2 @@ +def main(): + print("Hello world!")