Deploy Angular to AWS S3 with GitHub Actions

What You can directly push your angular build to aws s3 from github using github action. How For this you need aws iam with s3 access and cloudfront access ( if you are using CloudFront to serve the s3 resources ). the action script is name: Deploy to S3 on: push: branches: - master jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Node JS uses: actions/setup-node@v4 with: node-version: 'lts/*' - name: Install dependencies run: npm install --legacy-peer-deps - name: Build Angular project run: npm run build --configuration=production - name: Sync S3 bucket uses: jakejarvis/s3-sync-action@master with: args: --delete env: AWS_S3_BUCKET: your-bucket AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_REGION: 'eu-west-2' SOURCE_DIR: 'dist/proj' - name: Invalidate CloudFront uses: chetan/invalidate-cloudfront-action@v2 env: DISTRIBUTION: your-cf-id PATHS: "/*" AWS_REGION: "us-east-1" AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} In the script above, replace your-bucket with your bucket name, your-cf-id with your CloudFront distribution ID, and set the AWS IAM credentials in the GitHub repository secrets tab. ...

December 18, 2024 · 1 min · 190 words · Sagar Nayak