From cc7c72531506d965b23e91aa1bc1f7055d27fe01 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sun, 28 Sep 2025 23:40:36 +0200 Subject: [PATCH] Add Gitea deployment workflow --- .gitea/workflows/deploy.yml | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..6b32f6d --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,47 @@ + +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: Deploy to S3 and invalidate CloudFront + env: + BUCKET_NAME: ${{ secrets.BUCKET_NAME }} + CLOUDFRONT_ID: ${{ secrets.CLOUDFRONT_ID }} + run: | + aws s3 sync dist/ "s3://${BUCKET_NAME}" --delete --exclude "index.html" --cache-control "public, max-age=31536000, immutable" + aws s3 cp dist/index.html "s3://${BUCKET_NAME}/index.html" --cache-control "no-cache, no-store, must-revalidate" --content-type "text/html" + aws cloudfront create-invalidation --distribution-id "${CLOUDFRONT_ID}" --paths "/" "/index.html"