- Get link
- X
- Other Apps
YAML file that can be used to build and deploy an Angular project to AWS using a DevOps pipeline:
# .github/workflows/angular_aws.yml
name: Angular AWS Deployment
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install dependencies
run: npm ci
- name: Build Angular project
run: ng build --prod
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Deploy to AWS S3
run: aws s3 sync ./dist s3://your-bucket-name --delete
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation --distribution-id your-distribution-id --paths "/*"
Make sure to replace the following placeholders in the YAML file:
- `your-bucket-name`: Replace it with the name of the S3 bucket where you want to deploy your Angular project.
- `your-distribution-id`: Replace it with the ID of your CloudFront distribution.
To use this YAML file, you can create a new workflow file (e.g., `angular_aws.yml`) in the `.github/workflows` directory of your Angular project repository. The file can be committed to your repository, and the pipeline will automatically trigger on pushes to the `main` branch.
Additionally, you'll need to configure your AWS access key and secret access key as secrets in your GitHub repository settings. Replace `${{ secrets.AWS_ACCESS_KEY_ID }}` and `${{ secrets.AWS_SECRET_ACCESS_KEY }}` with the names of your AWS secrets.
This pipeline will build your Angular project, upload the built files to the specified S3 bucket, and invalidate the CloudFront cache to ensure the latest version of your application is served.
- Get link
- X
- Other Apps
Comments