From efbda5998a7c1be674a095d3f0d946911c82bed8 Mon Sep 17 00:00:00 2001 From: Shane Fontaine <9441295+shanefontaine@users.noreply.github.com> Date: Sat, 18 May 2024 08:38:30 -0700 Subject: [PATCH] gh: handle empty packages --- .github/workflows/docker-publish.yml | 1 + .github/workflows/npm-publish.yml | 1 + .github/workflows/publishable-packages.yml | 18 +++++++++++------- .github/workflows/ui-deploy.yml | 2 +- packages/sdk/src/config/index.ts | 2 +- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 33d97afc41..0de5941fc3 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -23,6 +23,7 @@ jobs: publish-docker: name: Publish Docker needs: publishable-packages + if: ${{ fromJson(needs.publishable-packages.outputs.publishable-packages)[0] != '' }} runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 951f885b95..99e1472b83 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -16,6 +16,7 @@ jobs: publish-sdk: name: Publish NPM needs: publishable-packages + if: ${{ fromJson(needs.publishable-packages.outputs.publishable-packages)[0] != '' }} runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/publishable-packages.yml b/.github/workflows/publishable-packages.yml index 2ff0bf8550..e642364fd8 100644 --- a/.github/workflows/publishable-packages.yml +++ b/.github/workflows/publishable-packages.yml @@ -18,7 +18,7 @@ jobs: publishable-packages: runs-on: ubuntu-latest outputs: - publishable-packages: ${{ steps.publishable-packages.outputs.modified_packages }} + publishable-packages: ${{ steps.publishable-packages.outputs.publishable_packages }} steps: - name: Checkout code uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b @@ -44,7 +44,7 @@ jobs: # Example: packages/hop-node,packages/v2-explorer-backend IFS=":" read -a input_packages <<< "${{ inputs.package-names }}" - modified_packages="" + publishable_packages="" for package in "${input_packages[@]}"; do package_path="packages/$package" @@ -62,15 +62,19 @@ jobs: fi fi - modified_packages+="$package," + publishable_packages+="$package," done # Strip the trailing comma # Example: packages/hop-node,packages/v2-explorer-backend - modified_packages="${modified_packages%,}" - + publishable_packages="${publishable_packages%,}" + # Convert from string with commas to array for consumption by matrix # Example: ["hop-node", "v2-explorer-backend"] - modified_packages=$(echo $modified_packages | tr ',' '\n' | sed 's/^ *//;s/ *$//' | jq -R -s -c 'split("\n")[:-1]') + if [ -z "$publishable_packages" ]; then + publishable_packages='[""]' + else + publishable_packages=$(echo $publishable_packages | tr ',' '\n' | sed 's/^ *//;s/ *$//' | jq -R -s -c 'split("\n")[:-1]') + fi - echo "modified_packages=$modified_packages" >> $GITHUB_OUTPUT \ No newline at end of file + echo "publishable_packages=$publishable_packages" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/.github/workflows/ui-deploy.yml b/.github/workflows/ui-deploy.yml index 14032e5181..f24f4a9e58 100644 --- a/.github/workflows/ui-deploy.yml +++ b/.github/workflows/ui-deploy.yml @@ -19,7 +19,7 @@ jobs: needs: publishable-packages runs-on: ubuntu-latest # If the frontend hasn't been modified, skip - if: ${{ fromJson(needs.publishable-packages.outputs.publishable-packages)[0] != null }} + if: ${{ fromJson(needs.publishable-packages.outputs.publishable-packages)[0] != '' }} environment: ${{ matrix.env-name }} strategy: matrix: diff --git a/packages/sdk/src/config/index.ts b/packages/sdk/src/config/index.ts index 2dacc8d0c6..6cec4beec7 100644 --- a/packages/sdk/src/config/index.ts +++ b/packages/sdk/src/config/index.ts @@ -5,7 +5,7 @@ import { config as goerli } from './goerli.js' import { config as mainnet } from './mainnet.js' import { config as sepolia } from './sepolia.js' -const cachebuster: number = 4 +const cachebuster: number = 5 let sdkConfig: any = {} const bondableChainsSet = new Set([])