stages:
    - deploy
    - bundle

deploy_production:
    stage: deploy
    tags:
        - production
    script:
        - export VERSION=$(sentry-cli releases propose-version)
        - sentry-cli releases new -p spnati $VERSION
        - bash ./prepare-online.sh
        - rsync -rltz --delete .public/ /opt/spnati
        - sentry-cli releases set-commits --auto $VERSION
        - sentry-cli releases finalize $VERSION
        - sentry-cli releases deploys $VERSION new -e production
    environment:
        name: production
        url: https://spnati.net/
    only:
        - master@spnati/spnati

bundle_packages:
    stage: bundle
    tags:
        - production
    script:
        - mkdir -p ./bundle-page/dl
        - python3 ./opponents/bundle.py ./ ./bundle-page/dl generate
        - rsync -rltz --delete ./bundle-page/ /opt/spnati-bundles
    only:
        - master@spnati/spnati