diff --git a/.github/workflows/sync-to-public.yml b/.github/workflows/sync-to-public.yml index f87e7bb..3e2aeed 100644 --- a/.github/workflows/sync-to-public.yml +++ b/.github/workflows/sync-to-public.yml @@ -10,12 +10,23 @@ jobs: sync: runs-on: ubuntu-latest steps: + - name: Check if token is set + run: | + if [ -z "${{ secrets.PUBLIC_REPO_TOKEN }}" ]; then + echo "❌ ERROR: PUBLIC_REPO_TOKEN secret is not set!" + exit 1 + else + echo "✅ PUBLIC_REPO_TOKEN is set" + fi + - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Remove sync workflow and push to public repo + env: + TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }} run: | # Configure git git config user.name "github-actions[bot]" @@ -28,6 +39,6 @@ jobs: git rm .github/workflows/sync-to-public.yml git commit -m "Remove sync workflow for public repo" - # Push to public repo - git remote add public https://x-access-token:${{ secrets.PUBLIC_REPO_TOKEN }}@github.com/wiestju/anny-booking-automation.git + # Push to public repo using env var (more secure) + git remote add public "https://x-access-token:${TOKEN}@github.com/wiestju/anny-booking-automation.git" git push public temp-sync-branch:main --force diff --git a/config/constants.py b/config/constants.py index b43c6ee..edcf239 100644 --- a/config/constants.py +++ b/config/constants.py @@ -12,4 +12,20 @@ DEFAULT_HEADERS = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0', 'accept': 'application/vnd.api+json', 'accept-encoding': 'plain' -} \ No newline at end of file +} + +# Booking time slots (in order of priority) +BOOKING_TIMES = [ + { + 'start': '14:00:00', + 'end': '19:00:00' + }, + { + 'start': '09:00:00', + 'end': '13:00:00' + }, + { + 'start': '20:00:00', + 'end': '23:45:00' + }, +] \ No newline at end of file diff --git a/main.py b/main.py index ca2a4a4..dc37466 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ from auth.session import AnnySession from booking.client import BookingClient from utils.helpers import get_future_datetime import pytz -from config.constants import RESOURCE_ID, TIMEZONE, SSO_PROVIDER +from config.constants import RESOURCE_ID, TIMEZONE, SSO_PROVIDER, BOOKING_TIMES def main(): load_dotenv('.env', override=True) @@ -40,22 +40,7 @@ def main(): elif seconds_until_midnight > max_wait_seconds: print(f"⚡ More than 10 min until midnight, executing immediately...") - times = [ - { - 'start': '14:00:00', - 'end': '19:00:00' - }, - { - 'start': '09:00:00', - 'end': '13:00:00' - }, - { - 'start': '20:00:00', - 'end': '24:00:00' - }, - ] - - for time_ in times: + for time_ in BOOKING_TIMES: try: start = get_future_datetime(hour=time_['start']) end = get_future_datetime(hour=time_['end'])