---
- name: Deploy staging environment
  hosts: all
  become: true

  tasks:
    - name: Pull {{ repo_branch }} branch
      ansible.builtin.git:
        repo: "{{ repo_url }}"
        dest: "{{ repo_dir }}"
        version: "{{ repo_branch }}"
        force: true
        accept_hostkey: true

    - name: Build and deploy staging
      ansible.builtin.include_role:
        name: app
        tasks_from: deploy_env
      vars:
        env: "{{ app_environments | selectattr('name', 'equalto', 'staging') | first }}"
