1+ name : CI/CD - AWS Glue Delta Lake Project
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+
8+ push :
9+ branches :
10+ - main
11+
12+ workflow_dispatch :
13+ inputs :
14+ force_deploy :
15+ description : " Deploy Glue scripts even if validation fails"
16+ required : true
17+ default : " false"
18+ type : choice
19+ options :
20+ - " false"
21+ - " true"
22+
23+ permissions :
24+ id-token : write
25+ contents : read
26+
27+ env :
28+ AWS_REGION : us-east-1
29+ GLUE_SCRIPT_BUCKET : wistia-data-bucket-001
30+ GLUE_SCRIPT_PREFIX : scripts/glue_jobs
31+
32+ jobs :
33+ validate-python :
34+ name : Validate Python code
35+ runs-on : ubuntu-latest
36+
37+ steps :
38+ - name : Check out repository
39+ uses : actions/checkout@v4
40+
41+ - name : Set up Python
42+ uses : actions/setup-python@v5
43+ with :
44+ python-version : " 3.11"
45+
46+ - name : Install development dependencies
47+ run : |
48+ python -m pip install --upgrade pip
49+ pip install -r requirements-dev.txt
50+
51+ - name : Run Ruff checks
52+ run : |
53+ ruff check glue_jobs streamlit_app
54+
55+ deploy-glue-scripts :
56+ name : Deploy Glue scripts to S3
57+ runs-on : ubuntu-latest
58+ needs : validate-python
59+
60+ if : |
61+ always() &&
62+ (
63+ (github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.validate-python.result == 'success') ||
64+ (github.event_name == 'workflow_dispatch' && inputs.force_deploy == 'true')
65+ )
66+
67+ steps :
68+ - name : Check out repository
69+ uses : actions/checkout@v4
70+
71+ - name : Configure AWS credentials
72+ uses : aws-actions/configure-aws-credentials@v4
73+ with :
74+ role-to-assume : arn:aws:iam::778277577883:role/wistia-github-actions-glue-deploy-role
75+ aws-region : ${{ env.AWS_REGION }}
76+
77+ - name : Upload Glue job scripts to S3
78+ run : |
79+ aws s3 sync glue_jobs/ s3://${GLUE_SCRIPT_BUCKET}/${GLUE_SCRIPT_PREFIX}/ \
80+ --delete \
81+ --exclude "__pycache__/*" \
82+ --exclude "*.pyc"
0 commit comments