workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
    - if: '$CI_COMMIT_TAG'
    - when: never

stages:
  - prepare
  - build
  - security
  - package
  - release
  - deploy

build:
  stage: build
  script:
    - ./scripts/build.sh
  artifacts:
    paths: [dist/]

unit_tests:
  stage: security
  needs:
    - job: build
      artifacts: true
  script:
    - ./scripts/test.sh

security_gate:
  stage: security
  needs:
    - unit_tests
  script:
    - ./scripts/security-gate.sh
  artifacts:
    access: developer
    paths: [reports/]

release:
  stage: release
  resource_group: release-main
  needs: [security_gate]
  rules:
    - if: '$CI_COMMIT_TAG'
  script:
    - ./scripts/release.sh
