From 6c799da86a9810e67a8448a66034aeeed0a6ca74 Mon Sep 17 00:00:00 2001 From: "Yuri (solarw) Turchenkov" Date: Fri, 2 Feb 2024 12:52:26 +0300 Subject: [PATCH 1/4] automated deployment on propel --- .github/workflows/release.yaml | 58 ++++++++++++++++++++++++- .github/workflows/test_release.yaml | 67 +++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test_release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c919cc64..4bd6e79b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,7 +2,7 @@ name: Release Flow on: release: - types: [published] + types: [prereleased, released] jobs: publish-packages: @@ -93,3 +93,59 @@ jobs: echo "Pushing $DOCKER_USER/oar-$AGENT:$DEFAULT_IMAGE_TAG" docker push $DOCKER_USER/oar-$AGENT:$VERSION docker push $DOCKER_USER/oar-$AGENT:$DEFAULT_IMAGE_TAG + deploy-service-on-propel: + name: Deploy service on propel + environment: ${{ github.event.action == 'released' && 'production' || 'staging' }} + needs: + - "publish-packages" + - "publish-images" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python-version: ["3.10"] + env: + CMD: "propel -U ${{ vars.PROPEL_BASE_URL }}" + steps: + - uses: actions/checkout@master + - uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-versions }} + - name: Install dependencies + run: | + sudo apt-get update --fix-missing + sudo apt-get autoremove + sudo apt-get autoclean + python -m pip install --upgrade pip + pip install propel-client==0.0.10 open-autonomy + + - name: Make use proxy instead of actual nlb by dns override + run: | + # for staging + export IP_ADDR=$(dig +short balancer.tcp.propel.staging.autonolas.tech) + echo -e "\n$IP_ADDR\tapp.propel.staging.valory.xyz\n" | sudo tee -a /etc/hosts + + # for prod + export IP_ADDR=$(dig +short balancer.tcp.propel.autonolas.tech) + echo -e "\n$IP_ADDR\tapp.propel.valory.xyz\n" | sudo tee -a /etc/hosts + + - name: Login to propel + run: | + $CMD login -u '${{ vars.PROPEL_USERNAME }}' -p '${{ secrets.PROPEL_PASSWORD }}' + + - name: Do a deployment + run: | + # determine ipfs hash id + export IPFS_HASH=$(jq '.dev | to_entries[] | select(.key | startswith("service"))| .value' -r ./packages/packages.json | head -n1) + export SERVICE_PATH=service_for_propel + + # fetch service file and check it published + autonomy init --reset --author ci --ipfs --remote + autonomy fetch $IPFS_HASH --service --alias $SERVICE_PATH + + # get env vars from github actions + echo '${{ toJSON(secrets) }}' | jq -r 'to_entries|map("export \(.key)=\(.value|tojson)")|.[]' > github.vars + echo >> github.vars + echo '${{ toJSON(vars) }}' | jq -r 'to_entries|map("export \(.key)=\(.value|tojson)")|.[]' >> github.vars + source github.vars + $CMD service deploy --name '${{ vars.SERVICE_NAME }}' --service-dir $SERVICE_PATH --service-ipfs-hash $IPFS_HASH --ingress-enabled true --keys '${{ vars.SERVICE_KEYS }}' --timeout 320 diff --git a/.github/workflows/test_release.yaml b/.github/workflows/test_release.yaml new file mode 100644 index 00000000..0f71db99 --- /dev/null +++ b/.github/workflows/test_release.yaml @@ -0,0 +1,67 @@ +name: release + +on: + push: + branches: + - develop + - main + pull_request: + +jobs: + deploy-service-on-propel: + name: Deploy service on propel + environment: 'staging' + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python-version: ["3.10"] + env: + CMD: "propel -U ${{ vars.PROPEL_BASE_URL }}" + steps: + - uses: actions/checkout@master + - uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-versions }} + - name: Install dependencies + run: | + sudo apt-get update --fix-missing + sudo apt-get autoremove + sudo apt-get autoclean + python -m pip install --upgrade pip + pip install propel-client==0.0.10 open-autonomy + + - name: Make use proxy instead of actual nlb by dns override + run: | + # for staging + export IP_ADDR=$(dig +short balancer.tcp.propel.staging.autonolas.tech) + echo -e "\n$IP_ADDR\tapp.propel.staging.valory.xyz\n" | sudo tee -a /etc/hosts + + # for prod + export IP_ADDR=$(dig +short balancer.tcp.propel.autonolas.tech) + echo -e "\n$IP_ADDR\tapp.propel.valory.xyz\n" | sudo tee -a /etc/hosts + + - name: Login to propel + run: | + $CMD login -u '${{ vars.PROPEL_USERNAME }}' -p '${{ secrets.PROPEL_PASSWORD }}' + + - name: Do a deployment + run: | + # determine ipfs hash id + export IPFS_HASH=$(jq '.dev | to_entries[] | select(.key | startswith("service"))| .value' -r ./packages/packages.json | head -n1) + export SERVICE_PATH=service_for_propel + + # fetch service file and check it published + autonomy init --reset --author ci --ipfs --remote + autonomy fetch $IPFS_HASH --service --alias $SERVICE_PATH + + # get env vars from github actions + echo "GET ENV VARS from secret" + echo '${{ toJSON(secrets) }}' | jq -r 'to_entries|map("export \(.key)=\(.value|tojson)")|.[]' > github.vars + echo >> github.vars + echo "GET ENV VARS from vars" + echo '${{ toJSON(vars) }}' | jq -r 'to_entries|map("export \(.key)=\(.value|tojson)")|.[]' >> github.vars + echo "GET ENV VARS done" + source github.vars + echo "GET ENV VARS load" + $CMD service deploy --name '${{ vars.SERVICE_NAME }}' --service-dir $SERVICE_PATH --service-ipfs-hash $IPFS_HASH --ingress-enabled true --keys '${{ vars.SERVICE_KEYS }}' --timeout 320 \ No newline at end of file From 974a40e6a57901f78f5259fda12ecb37b1b43653 Mon Sep 17 00:00:00 2001 From: "Yuri (solarw) Turchenkov" Date: Fri, 2 Feb 2024 13:49:54 +0300 Subject: [PATCH 2/4] ci release: new propel-client version --- .github/workflows/release.yaml | 2 +- .github/workflows/test_release.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4bd6e79b..ddbaf6e5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -117,7 +117,7 @@ jobs: sudo apt-get autoremove sudo apt-get autoclean python -m pip install --upgrade pip - pip install propel-client==0.0.10 open-autonomy + pip install propel-client==0.0.12 open-autonomy - name: Make use proxy instead of actual nlb by dns override run: | diff --git a/.github/workflows/test_release.yaml b/.github/workflows/test_release.yaml index 0f71db99..335f2152 100644 --- a/.github/workflows/test_release.yaml +++ b/.github/workflows/test_release.yaml @@ -29,7 +29,7 @@ jobs: sudo apt-get autoremove sudo apt-get autoclean python -m pip install --upgrade pip - pip install propel-client==0.0.10 open-autonomy + pip install propel-client==0.0.12 open-autonomy - name: Make use proxy instead of actual nlb by dns override run: | From efcef3016ef9cfe9a4fc7373036665d10e5c2245 Mon Sep 17 00:00:00 2001 From: "Yuri (solarw) Turchenkov" Date: Fri, 2 Feb 2024 14:28:13 +0300 Subject: [PATCH 3/4] ci release: unpin propel-client version --- .github/workflows/release.yaml | 2 +- .github/workflows/test_release.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ddbaf6e5..45b3bdb6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -117,7 +117,7 @@ jobs: sudo apt-get autoremove sudo apt-get autoclean python -m pip install --upgrade pip - pip install propel-client==0.0.12 open-autonomy + pip install propel-client open-autonomy - name: Make use proxy instead of actual nlb by dns override run: | diff --git a/.github/workflows/test_release.yaml b/.github/workflows/test_release.yaml index 335f2152..3d55adf4 100644 --- a/.github/workflows/test_release.yaml +++ b/.github/workflows/test_release.yaml @@ -29,7 +29,7 @@ jobs: sudo apt-get autoremove sudo apt-get autoclean python -m pip install --upgrade pip - pip install propel-client==0.0.12 open-autonomy + pip install propel-client open-autonomy - name: Make use proxy instead of actual nlb by dns override run: | From 2c206cb06d439062ed563dd48eb895b52ba279d3 Mon Sep 17 00:00:00 2001 From: "Yuri (solarw) Turchenkov" Date: Wed, 7 Feb 2024 11:22:23 +0300 Subject: [PATCH 4/4] add support for the second prod deployment schema --- .github/workflows/release.yaml | 2 +- .github/workflows/test_release.yaml | 67 ----------------------------- 2 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 .github/workflows/test_release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 45b3bdb6..fb31f354 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -95,7 +95,7 @@ jobs: docker push $DOCKER_USER/oar-$AGENT:$DEFAULT_IMAGE_TAG deploy-service-on-propel: name: Deploy service on propel - environment: ${{ github.event.action == 'released' && 'production' || 'staging' }} + environment: ${{ fromJSON('[["staging", "staging"], ["production", "shorts_production"]]')[github.event.action == 'released'][endsWith(github.event.release.name, '(shorts)')] }} needs: - "publish-packages" - "publish-images" diff --git a/.github/workflows/test_release.yaml b/.github/workflows/test_release.yaml deleted file mode 100644 index 3d55adf4..00000000 --- a/.github/workflows/test_release.yaml +++ /dev/null @@ -1,67 +0,0 @@ -name: release - -on: - push: - branches: - - develop - - main - pull_request: - -jobs: - deploy-service-on-propel: - name: Deploy service on propel - environment: 'staging' - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python-version: ["3.10"] - env: - CMD: "propel -U ${{ vars.PROPEL_BASE_URL }}" - steps: - - uses: actions/checkout@master - - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-versions }} - - name: Install dependencies - run: | - sudo apt-get update --fix-missing - sudo apt-get autoremove - sudo apt-get autoclean - python -m pip install --upgrade pip - pip install propel-client open-autonomy - - - name: Make use proxy instead of actual nlb by dns override - run: | - # for staging - export IP_ADDR=$(dig +short balancer.tcp.propel.staging.autonolas.tech) - echo -e "\n$IP_ADDR\tapp.propel.staging.valory.xyz\n" | sudo tee -a /etc/hosts - - # for prod - export IP_ADDR=$(dig +short balancer.tcp.propel.autonolas.tech) - echo -e "\n$IP_ADDR\tapp.propel.valory.xyz\n" | sudo tee -a /etc/hosts - - - name: Login to propel - run: | - $CMD login -u '${{ vars.PROPEL_USERNAME }}' -p '${{ secrets.PROPEL_PASSWORD }}' - - - name: Do a deployment - run: | - # determine ipfs hash id - export IPFS_HASH=$(jq '.dev | to_entries[] | select(.key | startswith("service"))| .value' -r ./packages/packages.json | head -n1) - export SERVICE_PATH=service_for_propel - - # fetch service file and check it published - autonomy init --reset --author ci --ipfs --remote - autonomy fetch $IPFS_HASH --service --alias $SERVICE_PATH - - # get env vars from github actions - echo "GET ENV VARS from secret" - echo '${{ toJSON(secrets) }}' | jq -r 'to_entries|map("export \(.key)=\(.value|tojson)")|.[]' > github.vars - echo >> github.vars - echo "GET ENV VARS from vars" - echo '${{ toJSON(vars) }}' | jq -r 'to_entries|map("export \(.key)=\(.value|tojson)")|.[]' >> github.vars - echo "GET ENV VARS done" - source github.vars - echo "GET ENV VARS load" - $CMD service deploy --name '${{ vars.SERVICE_NAME }}' --service-dir $SERVICE_PATH --service-ipfs-hash $IPFS_HASH --ingress-enabled true --keys '${{ vars.SERVICE_KEYS }}' --timeout 320 \ No newline at end of file