Skip to content

Commit

Permalink
chore: Access Secrets based on environments segregate (#231)
Browse files Browse the repository at this point in the history
* segregate secrets based on environments

* Added: Deployment Authorisation

* fixed: typo

* Added Authorisation
  • Loading branch information
eedygreen authored Oct 29, 2024
1 parent eb9f98d commit d4cedef
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 22 deletions.
27 changes: 19 additions & 8 deletions .github/workflows/deploy_mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,33 @@ on:
description: deploy v2
type: string

run-name: Deploy Explorer-Indexer to Mainnet - ${{ inputs.release_tag }} by @${{ github.actor }}

env:
AWS_REGION: '${{ secrets.AWS_REGION }}'
ENVIRONMENT: MAINNET
AWS_MAINNET: '${{ secrets.AWS_MAINNET }}'
REGISTRY: 'ghcr.io'
VERSION: ${{ inputs.release_tag }}

jobs:
deploy:
name: deploy
runs-on: ubuntu-latest

environment: mainnet
permissions:
contents: read
id-token: write
actions: write

env:
AWS_REGION: '${{ secrets.AWS_REGION }}'
AWS_MAINNET: '${{ secrets.AWS_MAINNET }}'
steps:
- name: Authorised User only
run: |
if [[ ! " tcar121293 eedygreen MakMuftic akchainsafe mpetrun5 " =~ " ${{ github.actor }} " ]]; then
echo "You are not authorized to deploy to mainnet!"
exit 1
fi
- name: checkout ecs repo
uses: actions/checkout@v4
with:
Expand All @@ -46,8 +55,8 @@ jobs:
awsAccountId=${{ env.AWS_MAINNET }}
awsRegion=${{ env.AWS_REGION }}
awsEnv=${{ env.ENVIRONMENT }}
DB_USERNAME=${{ secrets.MAIN_USERNAME }}
DB_PASSWORD=${{ secrets.MAIN_PASSWORD }}
DB_USERNAME=${{ secrets.DB_USERNAME }}
DB_PASSWORD=${{ secrets.DB_PASSWORD }}
imageTag=${{ env.VERSION }}
- name: Configure AWS Credentials
Expand Down Expand Up @@ -78,12 +87,14 @@ jobs:
# name: deploy v2

# runs-on: ubuntu-latest

# environment: mainnet
# permissions:
# contents: read
# id-token: write
# actions: write

# env:
# AWS_REGION: '${{ secrets.AWS_REGION }}'
# AWS_MAINNET: '${{ secrets.AWS_MAINNET }}'
# steps:
# - name: checkout ecs repo
# uses: actions/checkout@v4
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/deploy_mainnet_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,33 @@ on:
default: 'stable'
type: string

run-name: Deploy Explorer-API to Mainnet - ${{ inputs.release_tag }} by @${{ github.actor }}

env:
AWS_REGION: '${{ secrets.AWS_REGION }}'
ENVIRONMENT: MAINNET
AWS_MAINNET: '${{ secrets.AWS_MAINNET }}'
REGISTRY: 'ghcr.io'
VERSION: ${{ inputs.release_tag }}

jobs:
deploy:
name: deploy
runs-on: ubuntu-latest

environment: mainnet
permissions:
contents: read
id-token: write
actions: write

env:
AWS_REGION: '${{ secrets.AWS_REGION }}'
AWS_MAINNET: '${{ secrets.AWS_MAINNET }}'
steps:
- name: Authorised User only
run: |
if [[ ! " tcar121293 eedygreen MakMuftic akchainsafe mpetrun5 " =~ " ${{ github.actor }} " ]]; then
echo "You are not authorized to deploy to mainnet!"
exit 1
fi
- name: checkout ecs repo
uses: actions/checkout@v4
with:
Expand All @@ -44,8 +53,8 @@ jobs:
awsAccountId=${{ env.AWS_MAINNET }}
awsRegion=${{ env.AWS_REGION }}
awsEnv=${{ env.ENVIRONMENT }}
DB_USERNAME=${{ secrets.MAIN_USERNAME }}
DB_PASSWORD=${{ secrets.MAIN_PASSWORD }}
DB_USERNAME=${{ secrets.DB_USERNAME }}
DB_PASSWORD=${{ secrets.DB_PASSWORD }}
imageTag=${{ env.VERSION }}
- name: Configure AWS Credentials
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/deploy_testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ on:
types:
- published

run-name: Deploy Explorer-Indexer to Testnet - ${{ inputs.release_tag }} by @${{ github.actor }}

env:
AWS_REGION: '${{ secrets.AWS_REGION }}'
ENVIRONMENT: TESTNET
AWS_TESTNET: '${{ secrets.AWS_ARN }}'
REGISTRY: 'ghcr.io'
TAG: 'stable'
VERSION: ${{ github.event.release.tag_name }}
Expand Down Expand Up @@ -59,12 +59,14 @@ jobs:
needs: push
name: deploy
runs-on: ubuntu-latest

environment: testnet
permissions:
contents: read
id-token: write
actions: write

env:
AWS_REGION: '${{ secrets.AWS_REGION }}'
AWS_TESTNET: '${{ secrets.AWS_ARN }}'
steps:
- name: checkout ecs repo
uses: actions/checkout@v4
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/deploy_testnet_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ on:
types:
- published

run-name: Deploy Explorer-API to Testnet - ${{ inputs.release_tag }} by @${{ github.actor }}

env:
AWS_REGION: '${{ secrets.AWS_REGION }}'
ENVIRONMENT: TESTNET
AWS_TESTNET: '${{ secrets.AWS_ARN }}'
REGISTRY: 'ghcr.io'
TAG: 'stable'
VERSION: ${{ github.event.release.tag_name }}
Expand Down Expand Up @@ -61,12 +61,14 @@ jobs:
needs: push
name: deploy
runs-on: ubuntu-latest

environment: testnet
permissions:
contents: read
id-token: write
actions: write

env:
AWS_TESTNET: '${{ secrets.AWS_ARN }}'
AWS_REGION: '${{ secrets.AWS_REGION }}'
steps:
- name: checkout ecs repo
uses: actions/checkout@v4
Expand Down

0 comments on commit d4cedef

Please sign in to comment.