Ethereum ETL Deployment #82
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Ethereum ETL Deployment | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Dev/Prod env' | |
default: 'development' | |
type: choice | |
required: true | |
options: | |
- development | |
- production | |
env: | |
AWS_REGION: us-east-1 | |
ECR_REPOSITORY: ethereum-etl | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
setup-environment: | |
runs-on: ubuntu-latest | |
outputs: | |
environment: ${{ github.event.inputs.environment }} | |
steps: | |
- run: echo "null" | |
deploy: | |
name: Deploy | |
needs: [setup-environment] | |
runs-on: ubuntu-latest | |
environment: ${{ needs.setup-environment.outputs.environment }} | |
steps: | |
- name: Echo output | |
run: echo ${{ needs.setup-environment.outputs.environment }} | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials (Development) | |
if: github.event.inputs.environment == 'development' | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-session-name: Github | |
aws-region: ${{ env.AWS_REGION }} | |
role-to-assume: arn:aws:iam::679464682883:role/githubactions | |
- name: Configure AWS credentials (UAT) | |
if: github.event.inputs.environment == 'uat' | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-session-name: Github | |
aws-region: ${{ env.AWS_REGION }} | |
role-to-assume: arn:aws:iam::114810186946:role/githubactions | |
- name: Configure AWS credentials (Production) | |
if: github.event.inputs.environment == 'production' | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-session-name: Github | |
aws-region: ${{ env.AWS_REGION }} | |
role-to-assume: arn:aws:iam::114810186946:role/githubactions | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
IMAGE_TAG: ${{ github.sha }} | |
run: | | |
docker buildx build --platform=linux/amd64 -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |
- name: Repository Dispatch | |
env: | |
IMAGE_TAG: ${{ github.sha }} | |
EVENT_NAME: ${{ github.event.inputs.environment }}-ethereum-etl | |
VALUES_FILE: core/ethereum-values/ethereum-etl-values.yaml | |
run: | | |
curl -H "Accept: application/vnd.github.everest-preview+json" \ | |
-H "Authorization: token ${{ secrets.ACCESS_TOKEN_PWD }}" \ | |
--request POST \ | |
--data '{"event_type": "'"$EVENT_NAME"'", "client_payload": {"name": "'"$EVENT_NAME"'", "file_path": "'"$VALUES_FILE"'", "tag": "'"$IMAGE_TAG"'"}}' \ | |
https://api.github.com/repos/Airstack-xyz/infra-${{ github.event.inputs.environment }}-deployment/dispatches | |