Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sge #576

Closed
wants to merge 10 commits into from
Closed

Sge #576

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
242 changes: 242 additions & 0 deletions .github/workflows/build-artifact.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@

name: Build Artifacts

on:
push:
branches: [ sge ]
# pull_request:
# branches: [ master ]
workflow_dispatch:

jobs:
build_packages:
strategy:
matrix:
include:
- env: mainnet
cfg: "chains/mainnet/sge.json"
- env: testnet
cfg: "chains/testnet/sge.json"
- env: staging
cfg: "chains/testnet/sge_stage.json"
runs-on: ubuntu-latest
steps:
- name: Environment
run: export NODE_OPTIONS="--max_old_space_size=4096"

- name: Git Checkout Latest
uses: actions/checkout@v4

- name: Update config
run: |
if [ ${{ matrix.env }} != "mainnet" ]; then cp ${{ matrix.cfg }} chains/mainnet/sge.json; fi
rm chains/testnet/*
cp chains/mainnet/sge.json chains/testnet/sge.json

- name: Remove Google Analytics
run: |
sed -i '25,40d' index.html

- name: Install
run: yarn install --ignore-engines

- name: Build
run: yarn build

- name: Pack
run: |
mv dist/ pingpub
tar -czf pingpub_${{ matrix.env }}.tar.gz ./pingpub/

- uses: actions/upload-artifact@v4
id: upload
with:
name: pingpub_${{ matrix.env }}.tar.gz
path: pingpub_${{ matrix.env }}.tar.gz
retention-days: 1

build_image_staging:
needs: build_packages
runs-on: ubuntu-latest
outputs:
PINGPUB_AMI_STAGING: ${{ steps.extract.outputs.PINGPUB_AMI }}
permissions:
id-token: write
contents: read
steps:
- name: Checkout aws-infra
uses: actions/checkout@v4
with:
repository: 'saage-tech/aws-infra'
token: ${{ secrets.UPDATE_TGL }}

- name: Download
uses: actions/download-artifact@v4

- name: Assume role
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_STAGING }}
aws-region: ${{ secrets.AWS_REGION_STAGING }}

- name: Packer Init
run: |
cp pingpub_staging.tar.gz/pingpub_staging.tar.gz ./packer/blockexplorer/files/pingpub.tar.gz
cd packer/blockexplorer
packer init .

- name: Packer Build
working-directory: packer/blockexplorer
run: |
packer build -var-file=staging.pkvars.hcl blockexplorer.pkr.hcl

- name: Extract AMI_ID
id: extract
working-directory: packer/blockexplorer
run : |
AMI_ID=$(jq -r '.builds[-1].artifact_id' packer-manifest.json | cut -d ":" -f2)
echo "PINGPUB_AMI=$AMI_ID" >> $GITHUB_OUTPUT
echo $AMI_ID

build_image_testnet:
needs: build_packages
runs-on: ubuntu-latest
outputs:
PINGPUB_AMI_TESTNET: ${{ steps.extract.outputs.PINGPUB_AMI }}
permissions:
id-token: write
contents: read
steps:
- name: Checkout aws-infra
uses: actions/checkout@v4
with:
repository: 'saage-tech/aws-infra'
token: ${{ secrets.UPDATE_TGL }}

- name: Download
uses: actions/download-artifact@v4

- name: Assume role
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_TESTNET }}
aws-region: ${{ secrets.AWS_REGION_TESTNET }}

- name: Packer Init
run: |
cp pingpub_testnet.tar.gz/pingpub_testnet.tar.gz ./packer/blockexplorer/files/pingpub.tar.gz
cd packer/blockexplorer
packer init .

- name: Packer Build
working-directory: packer/blockexplorer
run: |
packer build -var-file=testnet.pkvars.hcl blockexplorer.pkr.hcl

- name: Extract AMI_ID
id: extract
working-directory: packer/blockexplorer
run : |
AMI_ID=$(jq -r '.builds[-1].artifact_id' packer-manifest.json | cut -d ":" -f2)
echo "PINGPUB_AMI=$AMI_ID" >> $GITHUB_OUTPUT
echo $AMI_ID

build_image_mainnet:
needs: build_packages
runs-on: ubuntu-latest
outputs:
PINGPUB_AMI_MAINNET: ${{ steps.extract.outputs.PINGPUB_AMI }}
permissions:
id-token: write
contents: read
steps:
- name: Checkout aws-infra
uses: actions/checkout@v4
with:
repository: 'saage-tech/aws-infra'
token: ${{ secrets.UPDATE_TGL }}

- name: Download
uses: actions/download-artifact@v4

- name: Assume role
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_MAINNET }}
aws-region: ${{ secrets.AWS_REGION_MAINNET }}

- name: Packer Init
run: |
cp pingpub_mainnet.tar.gz/pingpub_mainnet.tar.gz ./packer/blockexplorer/files/pingpub.tar.gz
cd packer/blockexplorer
packer init .

- name: Packer Build
working-directory: packer/blockexplorer
run: |
packer build -var-file=mainnet.pkvars.hcl blockexplorer.pkr.hcl

- name: Extract AMI_ID
id: extract
working-directory: packer/blockexplorer
run : |
ls -la
AMI_ID=$(jq -r '.builds[-1].artifact_id' packer-manifest.json | cut -d ":" -f2)
echo "PINGPUB_AMI=$AMI_ID" >> $GITHUB_OUTPUT
echo $AMI_ID

update_ami:
needs: [ build_image_staging, build_image_testnet, build_image_mainnet ]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout terragrunt code
uses: actions/checkout@v4
with:
repository: 'saage-tech/terragrunt-live-sgenetwork'
token: ${{ secrets.UPDATE_TGL }}

- name: Replace AMI IDs
env:
MAINNET_AMI: ${{ needs.build_image_mainnet.outputs.PINGPUB_AMI_MAINNET }}
TESTNET_AMI: ${{ needs.build_image_testnet.outputs.PINGPUB_AMI_TESTNET }}
STAGING_AMI: ${{ needs.build_image_staging.outputs.PINGPUB_AMI_STAGING }}
run: |
ls -la $GITHUB_WORKSPACE
cd ${GITHUB_WORKSPACE}/staging/us-east-1/blockchain/pingpub/instance/pingpub-priv
sed -i "s/aws_instance_ami =.*/aws_instance_ami = \"${STAGING_AMI}\"/g" terragrunt.hcl
cd ${GITHUB_WORKSPACE}/testnet/us-east-1/public-testnet-20221028/pingpub/instances/pingpub-priv
sed -i "s/aws_instance_ami =.*/aws_instance_ami = \"${TESTNET_AMI}\"/g" terragrunt.hcl
cd ${GITHUB_WORKSPACE}/mainnet/ap-northeast-2/blockchain/pingpub/instance/pingpub-priv
sed -i "s/aws_instance_ami =.*/aws_instance_ami = \"${MAINNET_AMI}\"/g" terragrunt.hcl

- name: Check terragrunt HCL mainnet
uses: gruntwork-io/terragrunt-action@v2
with:
tf_version: v1.3.3
tg_version: v0.42.3
tg_dir: mainnet/ap-northeast-2/blockchain/pingpub/instance/pingpub-priv
tg_command: 'hclfmt'

- name: Check terragrunt HCL testnet
uses: gruntwork-io/terragrunt-action@v2
with:
tf_version: v1.3.3
tg_version: v0.42.3
tg_dir: testnet/us-east-1/public-testnet-20221028/pingpub/instances/pingpub-priv
tg_command: 'hclfmt'

- name: Check terragrunt HCL staging
uses: gruntwork-io/terragrunt-action@v2
with:
tf_version: v1.3.3
tg_version: v0.42.3
tg_dir: staging/us-east-1/blockchain/pingpub/instance/pingpub-priv
tg_command: 'hclfmt'

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Automated Change - PingPub update
#push_options: --force
4 changes: 2 additions & 2 deletions .github/workflows/config-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name: Config Checker

on:
# push:
# branches: [ master ]
push:
branches: [ master, sge ]
pull_request:
# branches: [ master ]
paths:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/sync_repos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Sync repo

on:
schedule:
- cron: "0 1 * * 3"
workflow_dispatch:

jobs:
get_state:
runs-on: ubuntu-latest
outputs:
EXPLORER: ${{ steps.status.outputs.EXPLORER }}
UPDATE: ${{ steps.status.outputs.UPDATE }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get commits
id: status
run: |
echo "EXPLORER=$(git ls-remote -h https://github.com/ping-pub/explorer.git master | cut -f1)" >> $GITHUB_OUTPUT
grep '^${EXPLORER}$' pingpub.commit && echo "UPDATE=0" >> $GITHUB_OUTPUT || export echo "UPDATE=1" >> $GITHUB_OUTPUT

repo_sync:
needs: get_state
runs-on: ubuntu-latest
if: needs.get_state.outputs.UPDATE == 0 #Should be changed later
steps:
- name: Clone SGE Repo
uses: actions/checkout@v4
with:
ref: 'sge'

- name: Clone Original Repo
uses: actions/checkout@v4
with:
repository: 'ping-pub/explorer'
ref: 'master'
path: 'original'

- name: Update files
run: |
rm original/chains/mainnet/cosmos.json original/chains/mainnet/neutron.json original/chains/mainnet/nolus.json
rm original/chains/mainnet/osmosis.json original/chains/testnet/crossfi.json
cp -r ./original/* ./
rm -rf original/
echo $UPDATE > pingpub.commit

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: 'sge'
1 change: 1 addition & 0 deletions .github/workflows/testnet-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
steps:
- name: print
run: echo ${GITHUB_REF#refs/heads/}

- name: Git Checkout Latest
uses: actions/checkout@v2

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Your donation will help us make better products. Thanks in advance.

## Hire us

You can hire us by submiting an issue and fund the issue on [IssueHunter](https://issuehunt.io/r/ping-pub/explorer)
You can hire us by submitting an issue and fund the issue on [IssueHunter](https://issuehunt.io/r/ping-pub/explorer)


## Contributors
Expand Down
Loading
Loading