Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add workflow to fetch Advent of Code puzzles #11

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/fetch-puzzle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Fetch Puzzle

on:
schedule:
# Run at 17:00 UTC (5pm) from December 1-25
- cron: '0 17 1-25 12 *'
workflow_dispatch:
inputs:
year:
description: 'Year of puzzle'
required: true
type: string
day:
description: 'Day of puzzle'
required: true
type: string

permissions:
contents: write
issues: write

env:
AOC_SESSION: ${{ secrets.AOC_SESSION }}

jobs:
fetch-puzzle:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python with uv
uses: astral-sh/setup-uv@v4
with:
python-version: '3.12'

- name: Install dependencies
run: uv sync

- name: Download puzzle
id: download
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
YEAR="${{ github.event.inputs.year }}"
DAY="${{ github.event.inputs.day }}"
else
YEAR=$(date +%Y)
DAY=$(date +%-d)
fi
echo "Downloading puzzle for Year: $YEAR, Day: $DAY"
PART=$(uv run python advent_of_code.py download "$YEAR" "$DAY")
echo "part=$PART" >> "$GITHUB_OUTPUT"
echo "year=$YEAR" >> "$GITHUB_OUTPUT"
echo "day=$DAY" >> "$GITHUB_OUTPUT"

- name: Commit puzzle
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add puzzles/
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Add puzzle for Year ${{ steps.download.outputs.year }} Day ${{ steps.download.outputs.day }}"
git push
fi

- name: Trigger create puzzle issue workflow
run: |
gh workflow run create-puzzle-issue.yml \
-f year=${{ steps.download.outputs.year }} \
-f day=${{ steps.download.outputs.day }} \
-f part=${{ steps.download.outputs.part }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies = [
"httpx>=0.28.1",
"markdownify>=0.14.1",
"typer>=0.15.1",
"types-beautifulsoup4>=4.12.3",
"types-beautifulsoup4>=4.12.0",
]

[dependency-groups]
Expand Down Expand Up @@ -41,8 +41,10 @@ warn_unreachable = true
[tool.ruff]
target-version = "py312"
line-length = 100

[tool.ruff.lint]
select = ["ALL"]
ignore = ["D203", "D212"]
ignore = ["D203", "D212", "COM812", "ISC001"]

[tool.ruff.format]
quote-style = "double"
Expand Down
23 changes: 23 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading