Files
lenssim/.gitea/workflows/deploy.yml
T
nils ab5b1aefe0
Build & Deploy / build (push) Successful in 2m33s
Build & Deploy / deploy (push) Failing after 2m17s
Install aws cli using snap
2025-09-29 07:23:02 +02:00

67 lines
1.9 KiB
YAML

name: Build & Deploy
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
deploy:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
- 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: ${{ secrets.AWS_REGION }}
- name: Install AWS CLI
run: |
sudo apt update
sudo apt install snapd
sudo snap install aws-cli --classic
- name: Sync hashed assets to S3
env:
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
run: |
aws s3 sync dist/ "s3://${BUCKET_NAME}" \
--delete \
--exclude "index.html" \
--cache-control "public, max-age=31536000, immutable"
- name: Upload index.html
env:
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
run: |
aws s3 cp dist/index.html "s3://${BUCKET_NAME}/index.html" \
--cache-control "no-cache, no-store, must-revalidate" \
--content-type "text/html"
- name: Invalidate CloudFront
env:
CLOUDFRONT_ID: ${{ secrets.CLOUDFRONT_ID }}
run: |
aws cloudfront create-invalidation \
--distribution-id "${CLOUDFRONT_ID}" \
--paths "/" "/index.html"