From 7a06c946d126222cf45c32c34a718e54a484384f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20M=C5=82odzikowski?= Date: Tue, 23 May 2023 11:20:45 +0200 Subject: [PATCH] feat(ci): support fairground / mainnet variables for s3 and do not deploy trading to s3 bucket on main branch --- .github/workflows/publish-dist.yml | 50 ++++++++++++++++++------------ 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/.github/workflows/publish-dist.yml b/.github/workflows/publish-dist.yml index 59bb4a7ea..3222d8d8f 100644 --- a/.github/workflows/publish-dist.yml +++ b/.github/workflows/publish-dist.yml @@ -59,29 +59,39 @@ jobs: key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }} # https://docs.github.com/en/actions/learn-github-actions/contexts - - name: Define variables + - name: Define dist variables + if: ${{ github.event_name == 'push' }} run: | envName='' domain="vega.rocks" - if [[ "${{ github.event_name }}" = "push" ]]; then - if [[ "${{ github.ref }}" =~ .*release/.* ]]; then - envName="$(echo ${{ github.ref }} | rev | cut -d '/' -f 1 | rev)" - elif [[ "${{ github.ref }}" =~ .*develop$ ]]; then - envName="stagnet1" - elif [[ "${{ matrix.app}}" = "trading" ]] && [[ ${{ startsWith(github.ref, 'refs/tags/v') && 'true' || 'false' }} = "true" ]]; then - envName="mainnet" - elif [[ "${{ github.ref }}" =~ .*main$ ]]; then - envName="mainnet" - fi - if [[ "${envName}" = "mainnet" ]]; then - domain="vega.xyz" - fi - if [[ "${envName}" = "testnet" ]]; then - domain="fairground.wtf" - fi - bucketName="${{ matrix.app }}.${envName}.${domain}" - echo BUCKET_NAME=${bucketName} >> $GITHUB_ENV + bucketName='' + + if [[ "${{ github.ref }}" =~ .*release/.* ]]; then + envName="$(echo ${{ github.ref }} | rev | cut -d '/' -f 1 | rev)" + elif [[ "${{ github.ref }}" =~ .*develop$ ]]; then + envName="stagnet1" + elif [[ "${{ github.ref }}" =~ .*main$ ]]; then + envName="mainnet" + elif [[ "${{ matrix.app}}" = "trading" ]] && [[ "${{ startsWith(github.ref, 'refs/tags/v') && 'true' || 'false' }}" = "true" ]]; then + envName="mainnet" fi + + if [[ "${envName}" = "mainnet" ]]; then + domain="vega.xyz" + bucketName="${{ matrix.app }}.${domain}" + elif [[ "${envName}" = "testnet" ]]; then + domain="fairground.wtf" + bucketName="${{ matrix.app }}.${domain}" + fi + + if [[ -z "${bucketName}" ]]; then + bucketName="${{ matrix.app }}.${envName}.${domain}" + fi + + echo "bucket name: ${bucketName}" + echo "env name: ${envName}" + + echo BUCKET_NAME=${bucketName} >> $GITHUB_ENV echo ENV_NAME=${envName} >> $GITHUB_ENV - name: Build local dist @@ -158,7 +168,7 @@ jobs: # bucket creation in github.com/vegaprotocol/terraform//frontend - name: Publish dist to s3 uses: jakejarvis/s3-sync-action@master - if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v') }} + if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v') && ( matrix.app != 'trading' || (matrix.app == 'trading' && !endsWith(github.ref, 'main') ) ) }} with: args: --acl private --follow-symlinks --delete env: