Skip to content

Commit

Permalink
get cookie from env
Browse files Browse the repository at this point in the history
  • Loading branch information
Alextopher committed Nov 27, 2023
1 parent 707cdf0 commit e97b1ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
TEST_COOKIE: ${{ secrets.TEST_COOKIE }}
AOC_COOKIE: ${{ secrets.AOC_COOKIE }}
steps:
- uses: actions/checkout@v3
- name: Build
Expand Down
10 changes: 8 additions & 2 deletions aoc-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ pub fn get_input(input: TokenStream) -> TokenStream {
let input_file = std::path::Path::new(&input_file);

if !input_file.exists() {
// Step 3: include the cookie file
let cookie = include_str!("../../inputs/cookie.txt");
// Step 3: get the session from the cookie file, or from an environment variable
let mut cookie = std::env::var("AOC_COOKIE").ok();

if cookie.is_none() {
cookie = std::fs::read_to_string("inputs/cookie.txt").ok();
}

let cookie = cookie.expect("Failed to get cookie");

// Step 4: download the input file
let client = reqwest::blocking::Client::new();
Expand Down

0 comments on commit e97b1ae

Please sign in to comment.