mirror of
https://github.com/Sea-Haven-Industries/meal-order-manager.git
synced 2026-09-30 06:33:12 +00:00
Playwright-based menu scraper for Redefine Meals, self-contained HTML order form with S3/CloudFront hosting, DynamoDB-backed order submission via API Gateway, and automated payroll deduction reports via SES.
102 lines
3.3 KiB
YAML
102 lines
3.3 KiB
YAML
name: Weekly Menu Scrape & Publish
|
|
|
|
on:
|
|
schedule:
|
|
# Monday 8am EST = 13:00 UTC
|
|
- cron: '0 13 * * 1'
|
|
# Monday 8am EDT = 12:00 UTC
|
|
- cron: '0 12 * * 1'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
id-token: write
|
|
contents: read
|
|
|
|
jobs:
|
|
scrape-and-publish:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
AWS_REGION: us-east-1
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
pip install playwright boto3
|
|
playwright install chromium --with-deps
|
|
|
|
- name: Configure AWS credentials
|
|
uses: aws-actions/configure-aws-credentials@v4
|
|
with:
|
|
role-to-assume: ${{ secrets.AWS_DEPLOY_ROLE_ARN }}
|
|
aws-region: us-east-1
|
|
|
|
- name: Scrape menu
|
|
run: python3 src/scraper/scrape_menu.py
|
|
|
|
- name: Get stack outputs
|
|
id: stack
|
|
run: |
|
|
API_URL=$(aws cloudformation describe-stacks \
|
|
--stack-name meal-order-manager \
|
|
--query 'Stacks[0].Outputs[?OutputKey==`ApiUrl`].OutputValue' \
|
|
--output text)
|
|
FORM_BUCKET=$(aws cloudformation describe-stacks \
|
|
--stack-name meal-order-manager \
|
|
--query 'Stacks[0].Outputs[?OutputKey==`FormBucketName`].OutputValue' \
|
|
--output text)
|
|
DIST_ID=$(aws cloudformation describe-stacks \
|
|
--stack-name meal-order-manager \
|
|
--query 'Stacks[0].Outputs[?OutputKey==`DistributionId`].OutputValue' \
|
|
--output text)
|
|
FORM_URL=$(aws cloudformation describe-stacks \
|
|
--stack-name meal-order-manager \
|
|
--query 'Stacks[0].Outputs[?OutputKey==`FormUrl`].OutputValue' \
|
|
--output text)
|
|
echo "api_url=$API_URL" >> $GITHUB_OUTPUT
|
|
echo "form_bucket=$FORM_BUCKET" >> $GITHUB_OUTPUT
|
|
echo "dist_id=$DIST_ID" >> $GITHUB_OUTPUT
|
|
echo "form_url=$FORM_URL" >> $GITHUB_OUTPUT
|
|
|
|
- name: Get API key
|
|
id: apikey
|
|
run: |
|
|
API_KEY=$(aws secretsmanager get-secret-value \
|
|
--secret-id meal-order-manager/form-api-key \
|
|
--query 'SecretString' --output text)
|
|
echo "::add-mask::$API_KEY"
|
|
echo "api_key=$API_KEY" >> $GITHUB_OUTPUT
|
|
|
|
- name: Generate order form
|
|
run: |
|
|
python3 src/server/generate_form.py \
|
|
--api-url "${{ steps.stack.outputs.api_url }}" \
|
|
--api-key "${{ steps.apikey.outputs.api_key }}"
|
|
|
|
- name: Upload menu to DynamoDB
|
|
run: python3 scripts/upload_menu.py
|
|
|
|
- name: Upload form to S3
|
|
run: |
|
|
WEEK=$(date +%Y-W%U)
|
|
aws s3 cp "output/order-form-$WEEK.html" \
|
|
"s3://${{ steps.stack.outputs.form_bucket }}/index.html" \
|
|
--content-type "text/html" \
|
|
--cache-control "no-cache"
|
|
aws s3 cp "output/order-form-$WEEK.html" \
|
|
"s3://${{ steps.stack.outputs.form_bucket }}/archive/$WEEK.html" \
|
|
--content-type "text/html"
|
|
|
|
- name: Invalidate CloudFront cache
|
|
run: |
|
|
aws cloudfront create-invalidation \
|
|
--distribution-id "${{ steps.stack.outputs.dist_id }}" \
|
|
--paths "/index.html"
|
|
|
|
- name: Notify Slack
|
|
run: python3 scripts/notify_slack.py "${{ steps.stack.outputs.form_url }}"
|