image: atlassian/default-image:3

pipelines:
    pull-requests:
        "**":
            - step:
                name: Install Node Dependencies
                caches:
                    - node-modules
                    - npm
                    - nvm
                script:
                    - nvm install v17.2.0
                    - npm i -g npm@8
                    - npm ci
            - parallel:
                - step:
                    name: Lua Check
                    script:
                        - apt-get update
                        - apt-get -y install lua5.1
                        - apt-get -y install luarocks
                        - luarocks install luacheck
                        - luacheck .
                - step:
                    name: Lua Diagnostics
                    caches:
                        - node-modules
                        - npm
                        - nvm
                    script:
                        - nvm use v17.2.0
                        - npm run lua-diagnostics
    tags:
        "*":
            - step:
                name: Install Node Dependencies
                caches:
                    - node-modules
                    - npm
                    - nvm
                script:
                    - nvm install v17.2.0
                    - npm i -g npm@8
                    - npm ci
            - parallel:
                - step:
                    name: Lua Check
                    script:
                        - apt-get update
                        - apt-get -y install lua5.1
                        - apt-get -y install luarocks
                        - luarocks install luacheck
                        - luacheck .
                - step:
                    name: Lua Diagnostics
                    caches:
                        - node-modules
                        - npm
                        - nvm
                    script:
                        - nvm use v17.2.0
                        - npm run lua-diagnostics
            - step:
                name: Deploy to ContentDB
                caches:
                    - node-modules
                    - npm
                    - nvm
                script:
                    - nvm use v17.2.0
                    - npm run push:ci -- --token=$CONTENT_DB_X_BOWS_EXTRAS_TOKEN --title=$BITBUCKET_TAG
definitions:
    caches:
        node-modules: ./node_modules
        npm: ~/.npm
        nvm: ~/.nvm
