From f4d24726650cce49d1ed11fff2098c7b1238e4cd Mon Sep 17 00:00:00 2001 From: Florin Dzeladini Date: Mon, 25 Nov 2024 22:11:25 +0100 Subject: [PATCH] chore: ci-cd dev pipeline for test --- .../workflows/deploy-wallet-get-starknet.yml | 30 ++++++++++++--- .github/workflows/publish-npm.yml | 37 ++++++++++++++----- 2 files changed, 52 insertions(+), 15 deletions(-) diff --git a/.github/workflows/deploy-wallet-get-starknet.yml b/.github/workflows/deploy-wallet-get-starknet.yml index 71604099..fe94fa27 100644 --- a/.github/workflows/deploy-wallet-get-starknet.yml +++ b/.github/workflows/deploy-wallet-get-starknet.yml @@ -2,6 +2,12 @@ name: Deploy Wallet-UI and Get-starknet on: workflow_dispatch: + inputs: + environment: + description: 'Environment to deploy' + type: environment + required: true + jobs: prepare-deployment: environment: dev @@ -20,21 +26,32 @@ jobs: id: prepare_parameters run: | BASE=$(node -p "require('./packages/starknet-snap/package.json').version") - HASH=$(git rev-parse --short HEAD) - DATE=$(date +%Y%m%d) { echo "AWS_CLOUDFRONT_DISTRIBUTIONS_ID=${{ vars.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }}" echo "AWS_S3_GET_STARKNET_URL=${{ vars.AWS_S3_GET_STARKNET_URL }}" echo "AWS_S3_URL=${{ vars.AWS_S3_URL }}" echo "GET_STARKNET_PUBLIC_PATH=${{ vars.GET_STARKNET_PUBLIC_PATH }}" - echo "VERSION=${BASE}-dev-${HASH}-${DATE}" - echo "TAG=dev" - echo "ENV=dev" } >> "$GITHUB_OUTPUT" + + if [[ $ENV == "dev" ]]; then + HASH=$(git rev-parse --short HEAD) + DATE=$(date +%Y%m%d) + { + echo "VERSION=${BASE}-dev-${HASH}-${DATE}" + echo "ENV=dev" + } >> "$GITHUB_OUTPUT" + elif [[ $ENV == "production" ]]; then + { + echo "VERSION=${BASE}" + echo "ENV=prod" + } >> "$GITHUB_OUTPUT" + else + echo "Invalid environment" + exit 1 + fi outputs: VERSION: ${{ steps.prepare_parameters.outputs.VERSION }} TAG: ${{ steps.prepare_parameters.outputs.TAG }} - ENV: ${{ steps.prepare_parameters.outputs.ENV }} AWS_S3_GET_STARKNET_URL: ${{ steps.prepare_parameters.outputs.AWS_S3_GET_STARKNET_URL }} AWS_CLOUDFRONT_DISTRIBUTIONS_ID: ${{ steps.prepare_parameters.outputs.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }} AWS_S3_URL: ${{ steps.prepare_parameters.outputs.AWS_S3_URL }} @@ -85,6 +102,7 @@ jobs: runs-on: ubuntu-latest needs: - prepare-deployment + - install-build steps: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 6759f85b..fef55732 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -2,6 +2,12 @@ name: Publish NPM on: workflow_dispatch: + inputs: + environment: + description: 'Environment to deploy' + type: environment + required: true + jobs: prepare-deployment: environment: dev @@ -20,15 +26,28 @@ jobs: id: prepare_parameters run: | BASE=$(node -p "require('./packages/starknet-snap/package.json').version") - HASH=$(git rev-parse --short HEAD) - DATE=$(date +%Y%m%d) - { - echo "VERSION=${BASE}-dev-${HASH}-${DATE}" - echo "TAG=dev" - echo "ENV=dev" - echo "LOG_LEVEL=6" - } >> "$GITHUB_OUTPUT" - + if [[ $ENV == "dev" ]]; then + HASH=$(git rev-parse --short HEAD) + DATE=$(date +%Y%m%d) + { + echo "VERSION=${BASE}-dev-${HASH}-${DATE}" + echo "TAG=dev" + echo "ENV=dev" + echo "LOG_LEVEL=6" + } >> "$GITHUB_OUTPUT" + elif [[ $ENV == "production" ]]; then + { + echo "VERSION=${BASE}" + echo "TAG=latest" + echo "ENV=prod" + echo "LOG_LEVEL=0" + } >> "$GITHUB_OUTPUT" + else + echo "Invalid environment" + exit 1 + fi + + echo $GITHUB_OUTPUT outputs: VERSION: ${{ steps.prepare_parameters.outputs.VERSION }} TAG: ${{ steps.prepare_parameters.outputs.TAG }}