image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/coopdevstreball/python:3.8.12


badge_provisioning:
  stage: test
  script:
    - odoo_provisioning_version=$(yq -r .'odoo_provisioning_version' inventory/group_vars/all.yml)
    - VERSION=$(curl -Ss --header "PRIVATE-TOKEN:${BOT_ACCESS_TOKEN}" "https://git.coopdevs.org/api/v4/projects/131/repository/tags" | yq -r '.[0] | .name')
    - echo $VERSION
    - echo $odoo_provisioning_version
    - |
      if [[ "$VERSION" == "$odoo_provisioning_version" ]]; then
        COLOR='GREEN_2';
      else
        COLOR="BRIGHT_RED";
      fi
    - anybadge --style=gitlab-scoped --label=odoo_provisioning_version --value=$odoo_provisioning_version --file=odoo_provisioning_version.svg --color="$COLOR"
  artifacts:
    paths:
      - odoo_provisioning_version.svg
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

