Commit 10b9f5df authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

fix: sanitize empty variable test expressions

rewrite all '$SOME_VAR' test expressions to '($SOME_VAR != null && $SOME_VAR != "")'
parent e3a2c8eb
Loading
Loading
Loading
Loading
+23 −11
Original line number Diff line number Diff line
@@ -772,8 +772,11 @@ stages:
    # exclude if $CLEANUP_ALL_REVIEW set to 'force'
    - if: '$CLEANUP_ALL_REVIEW == "force"'
      when: never
    # only on non-production, non-integration branches, with ${{ cookiecutter.template_PREFIX }}_REVIEW_PROJECT set
    - if: '${{ cookiecutter.template_PREFIX }}_REVIEW_PROJECT && $CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
    # exclude if ${{ cookiecutter.template_PREFIX }}_REVIEW_PROJECT not set
    - if: '${{ cookiecutter.template_PREFIX }}_REVIEW_PROJECT == null || ${{ cookiecutter.template_PREFIX }}_REVIEW_PROJECT == ""'
      when: never
    # only on non-production, non-integration branches
    - if: '$CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'

# cleanup review env (automatically triggered once branches are deleted)
{{ cookiecutter.template_prefix }}-cleanup-review:
@@ -793,8 +796,11 @@ stages:
    # exclude tags
    - if: $CI_COMMIT_TAG
      when: never
    # only on non-production, non-integration branches, with ${{ cookiecutter.template_PREFIX }}_REVIEW_PROJECT set
    - if: '${{ cookiecutter.template_PREFIX }}_REVIEW_PROJECT && $CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
    # exclude if ${{ cookiecutter.template_PREFIX }}_REVIEW_PROJECT not set
    - if: '${{ cookiecutter.template_PREFIX }}_REVIEW_PROJECT == null || ${{ cookiecutter.template_PREFIX }}_REVIEW_PROJECT == ""'
      when: never
    # only on non-production, non-integration branches
    - if: '$CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
      when: manual
      allow_failure: true

@@ -813,8 +819,11 @@ stages:
  # TODO: use resource group
  resource_group: integration
  rules:
    # only on integration branch(es), with ${{ cookiecutter.template_PREFIX }}_INTEG_PROJECT set
    - if: '${{ cookiecutter.template_PREFIX }}_INTEG_PROJECT && $CI_COMMIT_REF_NAME =~ $INTEG_REF'
    # exclude if ${{ cookiecutter.template_PREFIX }}_INTEG_PROJECT not set
    - if: '${{ cookiecutter.template_PREFIX }}_INTEG_PROJECT == null || ${{ cookiecutter.template_PREFIX }}_INTEG_PROJECT == ""'
      when: never
    # only on integration branch(es)
    - if: '$CI_COMMIT_REF_NAME =~ $INTEG_REF'

# deploy to `staging` env (only on master branch)
{{ cookiecutter.template_prefix }}-staging:
@@ -831,8 +840,11 @@ stages:
  # TODO: use resource group
  resource_group: staging
  rules:
    # only on production branch(es), with ${{ cookiecutter.template_PREFIX }}_STAGING_PROJECT set
    - if: '${{ cookiecutter.template_PREFIX }}_STAGING_PROJECT && $CI_COMMIT_REF_NAME =~ $PROD_REF'
    # exclude if ${{ cookiecutter.template_PREFIX }}_STAGING_PROJECT not set
    - if: '${{ cookiecutter.template_PREFIX }}_STAGING_PROJECT == null || ${{ cookiecutter.template_PREFIX }}_STAGING_PROJECT == ""'
      when: never
    # only on production branch(es)
    - if: '$CI_COMMIT_REF_NAME =~ $PROD_REF'

# Deploy to production if on branch master and variable {{ cookiecutter.template_PREFIX }}_PROD_PROJECT defined and AUTODEPLOY_TO_PROD is set
{{ cookiecutter.template_prefix }}-production:
@@ -851,12 +863,12 @@ stages:
  # TODO: use resource group
  resource_group: production
  rules:
    # exclude non-production branches
    - if: '$CI_COMMIT_REF_NAME !~ $PROD_REF'
      when: never
    # exclude if ${{ cookiecutter.template_PREFIX }}_PROD_PROJECT not set
    - if: '${{ cookiecutter.template_PREFIX }}_PROD_PROJECT == null || ${{ cookiecutter.template_PREFIX }}_PROD_PROJECT == ""'
      when: never
    # exclude non-production branch(es)
    - if: '$CI_COMMIT_REF_NAME !~ $PROD_REF'
      when: never
    - if: '${{ cookiecutter.template_PREFIX }}_PROD_DEPLOY_STRATEGY == "manual"'
      when: manual
    - if: '${{ cookiecutter.template_PREFIX }}_PROD_DEPLOY_STRATEGY == "auto"'