Angular is an open-source web application framework. It is a TypeScript-based free and development platform for building WEB, desktop, and mobile applications.
Amazon S3 stands for the Simple Storage Service. It is a service (object storage) that provides industry-leading scalability, data availability, storage, security, and performance. It can also be used to retrieve any amount of data from anywhere.
GitHub is a source code and file storage service hosting platform for version control and collaboration using the git tool. To automate the software workflow service GitHub Actions service is used.
I. Create and configure the AWS Account on the Amazon S3 Service
Choose Create Bucket.
II. Github Actions to deploy Angular code to S3 Bucket
III. Create the Angular Application
Notes:
name: deploy
on:
workflow_run:
workflows: [formatting]
types: completed
jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- run: echo 'The triggering workflow passed'
build:
runs-on: ubuntu-latest
env:
AWS_S3_BUCKET: zehntech-consumer
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
aws-region: ap-south-1 # Use your bucket region here
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@master
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm install
# - name: Install Angular
# run: npm install -g @angular/cli@9.0.7
- name: Production Build
run: npm run build --prod
# Deploy to S3
# This is a third party action used to sync our production build app with the AWS S3 bucket
# For security purpose I am using secrets configured in project repo setting.
- name: Deploy to S3
uses: jakejarvis/s3-sync-action@v0.5.1
with:
# --acl public read => makes files publicly readable(i.e. makes sure that your bucket settings are also set to public)
# --delete => permanently deletes files in S3 bucket that are not present in latest build
args: --acl public-read --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_PRODUCTION_BUCKET_NAME }} # S3 bucket name
# note: use IAM role with limited role for below access-key-id and secret-access-key
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} # Access Key ID
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} # Access Secret Key
SOURCE_DIR: "dist/consumer-admin-web/" # build folder now
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'
IV. GitHub Actions Flow
3. The run of the GitHub Actions flow is validated.
Whenever you make the changes to your git repository, the updated code is deployed on the s3 bucket.