From 9158e3a840916bc53a55b6f3d20fac349d0f7820 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 6 Nov 2024 09:20:01 +0000 Subject: [PATCH] Add a CI workflow to deploy frontend (#35) Part of [Service provider auctions for web deployments](https://www.notion.so/Service-provider-auctions-for-web-deployments-104a6b22d47280dbad51d28aa3a91d75) Co-authored-by: Adw8 Reviewed-on: https://git.vdb.to/cerc-io/snowballtools-base/pulls/35 Co-authored-by: Prathamesh Musale Co-committed-by: Prathamesh Musale --- .gitea/workflows/deploy-frontend.yaml | 61 ++++++++++++ packages/deployer/config.yml | 8 +- packages/deployer/deploy-frontend.sh | 11 ++- ...nd.staging.sh => deploy-frontend.vaasl.sh} | 92 +++++++++++-------- 4 files changed, 125 insertions(+), 47 deletions(-) create mode 100644 .gitea/workflows/deploy-frontend.yaml rename packages/deployer/{deploy-frontend.staging.sh => deploy-frontend.vaasl.sh} (58%) diff --git a/.gitea/workflows/deploy-frontend.yaml b/.gitea/workflows/deploy-frontend.yaml new file mode 100644 index 00000000..1f604639 --- /dev/null +++ b/.gitea/workflows/deploy-frontend.yaml @@ -0,0 +1,61 @@ +name: Deploy Snowball frontend + +on: + push: + branches: + - main + +env: + REGISTRY_USER_KEY: ${{ secrets.REGISTRY_USER_KEY }} + REGISTRY_BOND_ID: ${{ secrets.REGISTRY_BOND_ID }} + DEPLOYER_LRN: lrn://vaasl-provider/deployers/webapp-deployer-api.apps.vaasl.io + AUTHORITY: laconic-deploy + +jobs: + deploy: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20.x] + + steps: + - name: Check out repository + uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Download yarn + run: | + curl -fsSL -o /usr/local/bin/yarn https://github.com/yarnpkg/yarn/releases/download/v1.22.21/yarn-1.22.21.js + chmod +x /usr/local/bin/yarn + + - name: Install dependencies + run: | + yarn install + + - name: Set up environment + run: | + # Create a .env file with the necessary variables + echo "REGISTRY_BOND_ID=$REGISTRY_BOND_ID" > packages/deployer/.env + echo "DEPLOYER_LRN=$DEPLOYER_LRN" >> packages/deployer/.env + echo "AUTHORITY=$AUTHORITY" >> packages/deployer/.env + + # Create a config file with necessary endpoints and secrets + cat > packages/deployer/config.yml </dev/null | jq -r -s ".[] | sort_by(.createTime) | reverse | [ .[] | select(.bondId == \"$REGISTRY_BOND_ID\") ] | .[0].attributes.version" | awk -F. -v OFS=. '{$NF += 1 ; print}') +NEW_APPLICATION_VERSION=$(yarn --silent laconic -c $CONFIG_FILE registry record list --type ApplicationRecord --all --name "deploy-frontend" 2>/dev/null | jq -r -s ".[] | sort_by(.createTime) | reverse | [ .[] | select(.bondId == \"$REGISTRY_BOND_ID\") ] | .[0].attributes.version" | awk -F. -v OFS=. '{$NF += 1 ; print}') if [ -z "$NEW_APPLICATION_VERSION" ] || [ "1" == "$NEW_APPLICATION_VERSION" ]; then # Set application-record version if no previous records were found NEW_APPLICATION_VERSION=0.0.1 fi -# Generate application-deployment-request.yml -cat >./staging-records/application-deployment-request.yml <./staging-records/application-record.yml <./records/application-record.yml <./records/application-deployment-request.yml <