Skip to content

Commit

Permalink
Add Deployment workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Divya Madala <[email protected]>
  • Loading branch information
Divyaasm committed Jan 28, 2025
1 parent e22aee3 commit 998c04b
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/beta-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Beta Deployment Workflow

on:
issue_comment:
types: [created]

jobs:
beta-deployment:
if: >-
github.event.issue.pull_request &&
contains(github.event.comment.body, 'Approve Beta Deployment')
name: Get approval for deployment
permissions:
id-token: write
contents: read
issues: read
pull-requests: read
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js and AWS CDK
uses: actions/setup-node@v4
with:
node-version: 18.x

- name: Install dependencies and build project
run: |
npm install
npm run build
- name: Install AWS CDK
run: npm install -g [email protected]

- name: Assume IAM Role
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.BETA_DEPLOYMENT_ROLE }}
aws-region: us-east-1

- name: Deploy
run: |
COMMAND_OUTPUT=$(npm run cdk diff -- OpenSearch-CI-Config-Beta -c useSsl=true -c serverAccessType=prefixList -c restrictServerAccessTo=${{secrets.PREFIX_LIST}})
echo "$COMMAND_OUTPUT" | grep -q "Number of stacks with differences: 0"
if [ $? -eq 0 ]; then
echo "No stack changes involved"
else
npm run cdk deploy -- OpenSearch-CI-Config-Beta -c useSsl=true -c serverAccessType=prefixList -c restrictServerAccessTo=${{secrets.PREFIX_LIST}}
npm run cdk deploy -- OpenSearch-CI-Beta -c useSsl=true -c authType=github -c dataRetention=true -c macAgent=true -c useProdAgents=true -c enableViews=true -c ignoreResourcesFailures=false -c serverAccessType=prefixList -c restrictServerAccessTo=${{secrets.PREFIX_LIST}}
fi
54 changes: 54 additions & 0 deletions .github/workflows/changeset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Create Change Set

on:
pull_request:
types: [opened, synchronize]
branches:
- main

jobs:
create-change-sets:
name: Create Change Sets for Beta and Prod
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js and AWS CDK
uses: actions/setup-node@v4
with:
node-version: 18.x

- name: Install dependencies and build project
run: |
npm install
npm run build
- name: Install AWS CDK
run: npm install -g [email protected]

- name: Assume IAM Role for Beta
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.BETA_DEPLOYMENT_ROLE }}
aws-region: us-east-1

- name: Create Change Set for Beta
run: |
npm run cdk diff -- OpenSearch-CI-Config-Beta -c useSsl=true -c serverAccessType=prefixList -c restrictServerAccessTo=${{ secrets.PREFIX_LIST }}
npm run cdk diff -- OpenSearch-CI-Beta -c useSsl=true -c authType=github -c dataRetention=true -c macAgent=true -c useProdAgents=true -c enableViews=true -c ignoreResourcesFailures=false -c serverAccessType=prefixList -c restrictServerAccessTo=${{secrets.PREFIX_LIST}}
- name: Assume IAM Role for Prod
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.PROD_DEPLOYMENT_ROLE }}
aws-region: us-east-1

- name: Create Change Set for Prod
run: |
npm run cdk diff -- OpenSearch-CI-Config-Prod -c useSsl=true -c serverAccessType=prefixList -c restrictServerAccessTo=${{ secrets.INTERNET_ACCESS }}
npm run cdk diff -- OpenSearch-CI-Prod -c useSsl=true -c authType=github -c dataRetention=true -c macAgent=true -c useProdAgents=true -c enableViews=true -c ignoreResourcesFailures=false -c serverAccessType=prefixList -c restrictServerAccessTo=${{secrets.PREFIX_LIST}}
51 changes: 51 additions & 0 deletions .github/workflows/prod-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Beta Deployment Workflow

on:
issue_comment:
types: [created]

jobs:
beta-deployment:
if: >-
github.event.issue.pull_request &&
contains(github.event.comment.body, 'Approve Prod Deployment')
name: Get approval for deployment
permissions:
id-token: write
contents: read
issues: read
pull-requests: read
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js and AWS CDK
uses: actions/setup-node@v4
with:
node-version: 18.x

- name: Install dependencies and build project
run: |
npm install
npm run build
- name: Install AWS CDK
run: npm install -g [email protected]

- name: Assume IAM Role
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.PROD_DEPLOYMENT_ROLE }}
aws-region: us-east-1

- name: Deploy
run: |
COMMAND_OUTPUT=$(npm run cdk diff -- OpenSearch-CI-Config-Prod -c useSsl=true -c serverAccessType=prefixList -c restrictServerAccessTo=${{secrets.PREFIX_LIST}})
echo "$COMMAND_OUTPUT" | grep -q "Number of stacks with differences: 0"
if [ $? -eq 0 ]; then
echo "No stack changes involved"
else
npm run cdk deploy -- OpenSearch-CI-Config-Prod -c useSsl=true -c serverAccessType=prefixList -c restrictServerAccessTo=${{secrets.PREFIX_LIST}}
npm run cdk deploy -- OpenSearch-CI-Prod -c useSsl=true -c authType=github -c dataRetention=true -c macAgent=true -c useProdAgents=true -c enableViews=true -c ignoreResourcesFailures=false -c serverAccessType=prefixList -c restrictServerAccessTo=${{secrets.PREFIX_LIST}}
fi

0 comments on commit 998c04b

Please sign in to comment.