From c3035014dbbe8c6a42b8dd801a3b112d27e7f249 Mon Sep 17 00:00:00 2001 From: Alex Gomez Date: Fri, 8 Nov 2024 13:59:40 +0100 Subject: [PATCH] refactor actions to a single one --- .github/actions/dev-ipfs-pin/action.yml | 95 ------------------- .../action.yml | 20 +--- .github/workflows/build-test-deploy-dev.yml | 5 +- .github/workflows/test-deploy-fork.yml | 5 +- .github/workflows/update-prod-staging.yml | 6 +- 5 files changed, 8 insertions(+), 123 deletions(-) delete mode 100644 .github/actions/dev-ipfs-pin/action.yml rename .github/actions/{production-ipfs-pin => ipfs-pin}/action.yml (80%) diff --git a/.github/actions/dev-ipfs-pin/action.yml b/.github/actions/dev-ipfs-pin/action.yml deleted file mode 100644 index 661a793d78..0000000000 --- a/.github/actions/dev-ipfs-pin/action.yml +++ /dev/null @@ -1,95 +0,0 @@ -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=220s \ - --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" diff --git a/.github/actions/production-ipfs-pin/action.yml b/.github/actions/ipfs-pin/action.yml similarity index 80% rename from .github/actions/production-ipfs-pin/action.yml rename to .github/actions/ipfs-pin/action.yml index 86d7ff2423..ee94fe5164 100644 --- a/.github/actions/production-ipfs-pin/action.yml +++ b/.github/actions/ipfs-pin/action.yml @@ -1,21 +1,9 @@ -name: Pin to private cluster -description: Upload build to ipfs nodes running in GKE +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 @@ -37,9 +25,9 @@ runs: continue-on-error: false shell: bash run: | + tar -czf app.tar.gz './${{ inputs.BUILD_PATH }}' rm -rf ./key - echo -n "${{ inputs.IPFS_SERVER_KEY }}" | base64 -d >> ./key - chmod 400 ./key + echo -n "${{ inputs.IPFS_SERVER_KEY }}" | base64 -d >> ./key && chmod 400 ./key - name: Upload build to IPFS Primary Server id: ipfs-scp-primary diff --git a/.github/workflows/build-test-deploy-dev.yml b/.github/workflows/build-test-deploy-dev.yml index b968af9eb7..303e0c57c1 100644 --- a/.github/workflows/build-test-deploy-dev.yml +++ b/.github/workflows/build-test-deploy-dev.yml @@ -127,11 +127,8 @@ jobs: - name: Pin to primary IPFS server id: ipfs-primary - uses: ./.github/actions/dev-ipfs-pin + uses: ./.github/actions/ipfs-pin with: - GCP_SA_KEY: '${{ secrets.GCP_SA_KEY }}' - GKE_CLUSTER: '${{ secrets.GKE_CLUSTER }}' - GKE_CLUSTER_REGION: '${{ secrets.GKE_CLUSTER_REGION }}' IPFS_SERVER_PORT: '${{ secrets.IPFS_PRIMARY_SERVER_PORT }}' IPFS_SERVER: '${{ secrets.IPFS_PRIMARY_SERVER }}' IPFS_SERVER_KEY: '${{ secrets.IPFS_PRIMARY_SERVER_KEY }}' diff --git a/.github/workflows/test-deploy-fork.yml b/.github/workflows/test-deploy-fork.yml index 03e876f976..874afe2830 100644 --- a/.github/workflows/test-deploy-fork.yml +++ b/.github/workflows/test-deploy-fork.yml @@ -138,11 +138,8 @@ jobs: - name: Pin to primary IPFS server id: ipfs-primary - uses: ./.github/actions/dev-ipfs-pin + uses: ./.github/actions/ipfs-pin with: - GCP_SA_KEY: '${{ secrets.GCP_SA_KEY }}' - GKE_CLUSTER: '${{ secrets.GKE_CLUSTER }}' - GKE_CLUSTER_REGION: '${{ secrets.GKE_CLUSTER_REGION }}' IPFS_SERVER_PORT: '${{ secrets.IPFS_PRIMARY_SERVER_PORT }}' IPFS_SERVER: '${{ secrets.IPFS_PRIMARY_SERVER }}' IPFS_SERVER_KEY: '${{ secrets.IPFS_PRIMARY_SERVER_KEY }}' diff --git a/.github/workflows/update-prod-staging.yml b/.github/workflows/update-prod-staging.yml index 5f0e07b19f..d21c2446fd 100644 --- a/.github/workflows/update-prod-staging.yml +++ b/.github/workflows/update-prod-staging.yml @@ -25,9 +25,8 @@ jobs: - name: Pin to primary IPFS server id: ipfs-primary - uses: ./.github/actions/production-ipfs-pin + uses: ./.github/actions/ipfs-pin with: - DOMAIN: app.aave.com IPFS_SERVER_PORT: '${{ secrets.IPFS_PRIMARY_SERVER_PORT }}' IPFS_SERVER: '${{ secrets.IPFS_PRIMARY_SERVER }}' IPFS_SERVER_KEY: '${{ secrets.IPFS_PRIMARY_SERVER_KEY }}' @@ -82,9 +81,8 @@ jobs: - name: Pin to primary IPFS server id: ipfs-primary - uses: ./.github/actions/production-ipfs-pin + uses: ./.github/actions/ipfs-pin with: - DOMAIN: staging.aave.com IPFS_SERVER_PORT: '${{ secrets.IPFS_PRIMARY_SERVER_PORT }}' IPFS_SERVER: '${{ secrets.IPFS_PRIMARY_SERVER }}' IPFS_SERVER_KEY: '${{ secrets.IPFS_PRIMARY_SERVER_KEY }}'