Skip to content

Commit

Permalink
Edit: deploy change for check CloudFront Cache prob
Browse files Browse the repository at this point in the history
  • Loading branch information
dreekz committed Dec 16, 2024
1 parent f60079e commit 1376e9a
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,58 @@ name: Deploy Static Website to AWS S3 and CloudFront
on:
push:
branches:
- main # מפעיל את ה-Workflow בכל דחיפה ל-main
workflow_dispatch: # מאפשר הרצה ידנית דרך GitHub Actions
- main
workflow_dispatch:

env:
BUCKET_NAME: yarinakiva-dev-website2
DISTRIBUTION_ID: E1O0O1DKZKX1E2

jobs:
deploy:
runs-on: ubuntu-latest # הרצה על Ubuntu

runs-on: ubuntu-latest
steps:
# שלב 1: Checkout של הקוד מהריפו
- name: Checkout repository
uses: actions/checkout@v3

# שלב 2: התקנת Python ו-MkDocs
- name: Install Python and MkDocs
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: '3.9'
cache: 'pip'

# שלב 3: התקנת התלויות של MkDocs
- name: Install MkDocs dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mkdocs mkdocs-material
# שלב 4: בניית האתר באמצעות MkDocs
- name: Build MkDocs site
- name: Build site
run: mkdocs build

# שלב 5: הגדרת AWS Credentials
- name: Configure AWS Credentials
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1 # עדכן לאזור של ה-Bucket שלך
aws-region: us-east-1

# שלב 6: העלאת האתר ל-S3
- name: Deploy to S3
- name: Upload to S3
run: |
aws s3 sync ./site s3://yarinakiva-dev-website2 --delete --cache-control "no-cache, no-store, must-revalidate"
# שלב 7: ביצוע Invalidation ב-CloudFront
- name: Invalidate CloudFront cache
aws s3 sync ./site s3://${{ env.BUCKET_NAME }} \
--delete \
--cache-control "max-age=3600" \
--exclude "*.html" \
--exclude "*.css" \
--exclude "*.js"
aws s3 sync ./site s3://${{ env.BUCKET_NAME }} \
--delete \
--cache-control "no-cache" \
--include "*.html" \
--include "*.css" \
--include "*.js"
- name: Invalidate CloudFront
run: |
aws cloudfront create-invalidation --distribution-id E1O0O1DKZKX1E2 --paths "/*"
aws cloudfront create-invalidation \
--distribution-id ${{ env.DISTRIBUTION_ID }} \
--paths "/*

0 comments on commit 1376e9a

Please sign in to comment.