From 751ea2dddac9415fc2e3322a5049a93e401d339f Mon Sep 17 00:00:00 2001 From: Michal Gubricky Date: Thu, 8 Aug 2024 14:54:22 +0200 Subject: [PATCH] :bug: Add checkout to PR banch into e2e tests (#145) * Add checkout to PR banch into e2e tests Signed-off-by: michal.gubricky * Simplify 'Set facts' task name Signed-off-by: Roman Hros --------- Signed-off-by: michal.gubricky Signed-off-by: Roman Hros Co-authored-by: Roman Hros --- playbooks/openstack/e2e.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/playbooks/openstack/e2e.yaml b/playbooks/openstack/e2e.yaml index 4a3fc3d2..f71f6088 100644 --- a/playbooks/openstack/e2e.yaml +++ b/playbooks/openstack/e2e.yaml @@ -21,6 +21,27 @@ 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 when the e2e pipeline is initiated on a PR + 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 }}"