Skip to content

Commit

Permalink
Add checkout to PR banch into e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: michal.gubricky <[email protected]>
  • Loading branch information
michal-gubricky committed Jul 22, 2024
1 parent a516c90 commit f7e00f8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions playbooks/openstack/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@
tasks:
- name: Determine cluster stack directory
block:
- name: Get PR details
ansible.builtin.uri:
url: "https://api.github.com/repos/{{ zuul.project.name }}/pulls/{{ zuul.change }}"
body_format: json
headers:
Accept: application/vnd.github+json
X-GitHub-Api-Version: 2022-11-28
register: pull_request
when: zuul.change is defined # execute when the e2e pipeline is initiated on a PR
- name: |
Set facts -
In cases where e2e is not executed on the PR, the main branch is used for the pipeline.
ansible.builtin.set_fact:
git_branch_name: "{{ pull_request.json.head.ref }}"
git_repository_url: "{{ pull_request.json.head.repo.clone_url }}"
when: zuul.change is defined # execute when the e2e pipeline is initiated on a PR
- name: Checkout to PR branch
ansible.builtin.git:
repo: "{{ git_repository_url }}"
clone: false
dest: "{{ project_dir }}"
version: "{{ git_branch_name }}"
when: zuul.change is defined # execute when the e2e pipeline is initiated on a PR
- name: Make sure directory structure exists
ansible.builtin.file:
path: "{{ item }}"
Expand Down

0 comments on commit f7e00f8

Please sign in to comment.