steps:
  test:
    image: node
    commands:
      - yarn --pure-lockfile
      - yarn run test

  build-latest-container:
    when:
      branch: main
      event: tag
    image: plugins/docker
    settings:
      registry: https://codeberg.org/v2
      username:
        from_secret: codeberg_username
      password:
        from_secret: codeberg_password
      repo: codeberg.org/keyoxide/keyoxide-web
      tags: latest

  build-tag-container:
    when:
      branch: main
      event: tag
    image: plugins/docker
    settings:
      registry: https://codeberg.org/v2
      username:
        from_secret: codeberg_username
      password:
        from_secret: codeberg_password
      repo: codeberg.org/keyoxide/keyoxide-web
      auto_tag: true

  build-dev-container:
    when:
      branch: dev
      event: push
    image: plugins/docker
    settings:
      registry: https://codeberg.org/v2
      username:
        from_secret: codeberg_username
      password:
        from_secret: codeberg_password
      repo: codeberg.org/keyoxide/keyoxide-web
      tags: dev