Skip to content

Commit

Permalink
Merge branch 'main' into feat/tx-history
Browse files Browse the repository at this point in the history
  • Loading branch information
foodaka committed Oct 6, 2023
2 parents a2cd5a0 + 955958b commit bb2bfe2
Show file tree
Hide file tree
Showing 17 changed files with 3,991 additions and 126 deletions.
95 changes: 95 additions & 0 deletions .github/actions/dev-ipfs-pin/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Pin to ipfs cluster and nodes
description: Upload build to ipfs node
inputs:
BUILD_PATH:
description: path to the build directory
required: true
DOMAIN:
description: Domain to unpin
required: true
GCP_SA_KEY:
description: ''
required: true
GKE_CLUSTER:
description: ''
required: true
GKE_CLUSTER_REGION:
description: ''
required: true
PINATA_HASH:
description: ''
required: true
IPFS_SERVER_PORT:
description: ''
required: true
IPFS_SERVER:
description: ''
required: true
IPFS_SERVER_KEY:
description: ''
required: true

runs:
using: 'composite'
steps:
- name: GCP Auth
uses: google-github-actions/auth@ceee102ec2387dd9e844e01b530ccd4ec87ce955 # v0.8.0
with:
credentials_json: '${{ inputs.GCP_SA_KEY }}'
- name: Get GKE credentials
uses: google-github-actions/get-gke-credentials@054fdb05e32039f72764f03e69e6acb20caa6f56 # v0.8.0
with:
cluster_name: '${{ inputs.GKE_CLUSTER }}'
location: '${{ inputs.GKE_CLUSTER_REGION }}'
- uses: azure/setup-kubectl@7f7e5ba5ea3e491b92e6e8e5819963f8f3a1f076 # v3
with:
version: 'v1.22.13'

- name: GKE ipfs cluster pin
shell: bash
run: |
export POD_NAME="ipfs-cluster-$(($RANDOM % 3))"
tar -czf app.tar.gz './${{ inputs.BUILD_PATH }}'
kubectl -n ipfs-cluster cp -c ipfs ./app.tar.gz ${POD_NAME}:/root/
echo "Uploading build..."
IPFS_HASH="$(kubectl -n ipfs-cluster exec -i ${POD_NAME} -c ipfs -- sh -c \
'cd /root/ && tar -zxf app.tar.gz && \
ipfs add -rQ --cid-version=1 --pin=false ./${{ inputs.BUILD_PATH }}/ && \
rm -rf ./app.tar.gz ./${{ inputs.BUILD_PATH }}')"
echo "Pinning to cluster..."
kubectl -n ipfs-cluster exec -i ${POD_NAME} -c ipfs-cluster -- \
ipfs-cluster-ctl pin add --wait --wait-timeout=180s \
--replication-min=1 --name='app-aave-${{ github.sha }}' \
"${IPFS_HASH}"
- name: Prepare env and Compress build on IPFS servers
id: ipfs-prepare
continue-on-error: false
shell: bash
run: |
rm -rf ./key
echo -n "${{ inputs.IPFS_SERVER_KEY }}" | base64 -d >> ./key
chmod 400 ./key
- name: Upload build to IPFS Primary Server
id: ipfs-scp-primary
continue-on-error: false
shell: bash
run: |
scp -o StrictHostKeyChecking=no \
-i ./key \
-P \${{ inputs.IPFS_SERVER_PORT }} app.tar.gz ipfs@\${{ inputs.IPFS_SERVER }}:.
ssh -o StrictHostKeyChecking=no \
-p \${{ inputs.IPFS_SERVER_PORT }} \
-i ./key ipfs@\${{ inputs.IPFS_SERVER }} "tar zxf app.tar.gz && ipfs add -rQ --cid-version=1 ./${{ inputs.BUILD_PATH }}/"
- name: Clean build and tmp directory on Servers
continue-on-error: false
id: ipfs-clean
shell: bash
run: |
ssh -o StrictHostKeyChecking=no \
-p \${{ inputs.IPFS_SERVER_PORT }} \
-i ./key ipfs@\${{ inputs.IPFS_SERVER }} "rm -rf ./${{ inputs.BUILD_PATH }}/ app.tar.gz"
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Pin to private cluster
description: Upload build to ipfs nodes running in GKE
inputs:
BUILD_PATH:
description: path to the build directory
required: true
DOMAIN:
description: Domain to unpin
required: true
Expand All @@ -13,12 +16,19 @@ inputs:
GKE_CLUSTER_REGION:
description: ''
required: true
BUILD_PATH:
description: path to the build directory
required: true
PINATA_HASH:
description: ''
required: true
IPFS_SERVER_PORT:
description: ''
required: true
IPFS_SERVER:
description: ''
required: true
IPFS_SERVER_KEY:
description: ''
required: true

runs:
using: 'composite'
steps:
Expand Down Expand Up @@ -58,3 +68,33 @@ runs:
ipfs-cluster-ctl pin add --wait --wait-timeout=180s \
--replication-min=1 --name='app-aave-${{ github.sha }}' \
"${IPFS_HASH}"
- name: Prepare env and Compress build on IPFS servers
id: ipfs-prepare
continue-on-error: false
shell: bash
run: |
rm -rf ./key
echo -n "${{ inputs.IPFS_SERVER_KEY }}" | base64 -d >> ./key
chmod 400 ./key
- name: Upload build to IPFS Primary Server
id: ipfs-scp-primary
continue-on-error: false
shell: bash
run: |
scp -o StrictHostKeyChecking=no \
-i ./key \
-P \${{ inputs.IPFS_SERVER_PORT }} app.tar.gz ipfs@\${{ inputs.IPFS_SERVER }}:.
ssh -o StrictHostKeyChecking=no \
-p \${{ inputs.IPFS_SERVER_PORT }} \
-i ./key ipfs@\${{ inputs.IPFS_SERVER }} "tar zxf app.tar.gz && ipfs add -rQ --cid-version=1 ./${{ inputs.BUILD_PATH }}/"
- name: Clean build and tmp directory on Servers
continue-on-error: false
id: ipfs-clean
shell: bash
run: |
ssh -o StrictHostKeyChecking=no \
-p \${{ inputs.IPFS_SERVER_PORT }} \
-i ./key ipfs@\${{ inputs.IPFS_SERVER }} "rm -rf ./${{ inputs.BUILD_PATH }}/ app.tar.gz"
Loading

0 comments on commit bb2bfe2

Please sign in to comment.