Skip to content

Commit ca8d6e6

Browse files
author
aleph
committed
chore: ✨ add commit linting job and update AWS deployment workflow
1 parent 454149f commit ca8d6e6

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

.github/workflows/deploy-aws.yml

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,29 @@ permissions:
88
contents: read
99
id-token: write # Required for AWS OIDC authentication
1010

11-
env:
12-
AWS_REGION: us-east-1
13-
S3_BUCKET: pythoncdmx-website
14-
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
1511

1612
jobs:
13+
commit_lint:
14+
name: Validate Commit Messages
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Validate PR Title
22+
uses: wagoid/commitlint-github-action@v5
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
with:
26+
configFile: .commitlintrc.json
27+
1728
build-and-deploy:
29+
needs: commit_lint
1830
name: Build and Deploy to AWS
1931
runs-on: ubuntu-latest
32+
environment:
33+
name: aws-prod
2034
steps:
2135
- name: Checkout repository
2236
uses: actions/checkout@v4
@@ -43,38 +57,42 @@ jobs:
4357
uses: aws-actions/configure-aws-credentials@v4
4458
with:
4559
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
46-
aws-region: ${{ env.AWS_REGION }}
60+
aws-region: ${{ secrets.AWS_REGION }}
4761

4862
- name: Sync to S3
4963
run: |
50-
aws s3 sync site/ s3://${{ env.S3_BUCKET }}/ \
64+
aws s3 sync site/ s3://${{ secrets.AWS_S3_BUCKET }}/ \
5165
--delete \
5266
--cache-control "public, max-age=3600" \
5367
--exclude "*.html" \
5468
--exclude "sitemap.xml"
5569
5670
# Upload HTML files with shorter cache
57-
aws s3 sync site/ s3://${{ env.S3_BUCKET }}/ \
71+
aws s3 sync site/ s3://${{ secrets.AWS_S3_BUCKET }}/ \
5872
--cache-control "public, max-age=600, must-revalidate" \
5973
--content-type "text/html; charset=utf-8" \
6074
--exclude "*" \
6175
--include "*.html"
6276
6377
# Upload sitemap with no cache
64-
aws s3 sync site/ s3://${{ env.S3_BUCKET }}/ \
78+
aws s3 sync site/ s3://${{ secrets.AWS_S3_BUCKET }}/ \
6579
--cache-control "public, max-age=0, must-revalidate" \
6680
--exclude "*" \
6781
--include "sitemap.xml"
82+
83+
cleanup-staging:
84+
name: Stop Staging Site
85+
needs: build-and-deploy
86+
runs-on: ubuntu-latest
87+
environment:
88+
name: aws-stag
89+
steps:
90+
- name: Configure AWS credentials
91+
uses: aws-actions/configure-aws-credentials@v4
92+
with:
93+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
94+
aws-region: ${{ secrets.AWS_REGION }}
6895

69-
- name: Invalidate CloudFront cache
70-
run: |
71-
aws cloudfront create-invalidation \
72-
--distribution-id ${{ env.CLOUDFRONT_DISTRIBUTION_ID }} \
73-
--paths "/*"
74-
75-
- name: Deployment summary
96+
- name: Stop Staging Site
7697
run: |
77-
echo "✅ Website deployed successfully!"
78-
echo "🌐 URL: https://pythoncdmx.org"
79-
echo "📦 S3 Bucket: ${{ env.S3_BUCKET }}"
80-
echo "🚀 CloudFront Distribution: ${{ env.CLOUDFRONT_DISTRIBUTION_ID }}"
98+
aws s3 rm s3://${{ secrets.AWS_S3_BUCKET }}/staging/ --recursive

0 commit comments

Comments
 (0)