Skip to content

Create Wallet

Create Wallet #53

Workflow file for this run

name: "Create Wallet"
on:
workflow_dispatch:
inputs:
env_name:
description: "Environment"
default: "mahmoud_matin"
required: true
type: choice
options:
- mahmoud_matin
- mahmoud_reyhoon
- mahmoud_baba
- mahmoud_maman
- julia_jack
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
jobs:
terraform:
name: "Create wallet (terraform apply)"
environment: ${{ github.event.inputs.env_name }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout the repository to the runner
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: pip3.10 install -r requirements.txt
- name: Run unit tests
run: python3.10 -m unittest discover -s test -p "test_*.py"
- name: Create the deployment package
run: bash create_deployment_package.sh
- name: Create .tfvars file
id: gen_tfvars
run: |
python3.10 tfvars.py ${{ secrets.BOT_TOKEN }} ${{ secrets.USER1 }} ${{ secrets.USER2 }} ${{ secrets.WALLET1 }} ${{ secrets.WALLET2 }} ${{ secrets.WALLET3 }}
USERNAME1=$(grep 'username1' terraform/terraform.tfvars | awk -F'"' '{print $2}')
USERNAME2=$(grep 'username2' terraform/terraform.tfvars | awk -F'"' '{print $2}')
echo "USERNAME1=${USERNAME1}" >> $GITHUB_ENV
echo "USERNAME2=${USERNAME2}" >> $GITHUB_ENV
- name: Setup terraform
uses: hashicorp/setup-terraform@v3
- name: Terraform fmt
id: fmt
run: cd terraform && terraform fmt terraform.tfvars && terraform fmt -check
continue-on-error: false
- name: Terraform init
id: init
run: |
cd terraform
terraform init \
-backend-config="key=sw-${USERNAME1}-${USERNAME2}"
- name: Terraform validate
id: validate
run: cd terraform && terraform validate -no-color
- name: Terraform plan
id: plan
run: cd terraform && terraform plan -no-color -lock-timeout=360s -var-file=terraform.tfvars
continue-on-error: false
- name: Terraform apply
id: apply
run: |
cd terraform
terraform apply -auto-approve -no-color -lock-timeout=360s -var-file=terraform.tfvars
echo "API_GATEWAY_URL=$(terraform output -raw api_gateway_url)" >> $GITHUB_ENV
- name: Set webhook of the bot
run: |
curl -X POST "https://api.telegram.org/bot${{ secrets.BOT_TOKEN }}/setWebhook?url=${API_GATEWAY_URL}/webhook"