Skip to content

Add prefix to automated branch names #372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
cmd: |
gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/{{ owner }}/{{ repository_manifest.name }}/git/ref/heads/{{ community_manifest.branch }}-community-files
/repos/{{ owner }}/{{ repository_manifest.name }}/git/ref/heads/{{ community_manifest.prefix | default("") }}{{ community_manifest.branch }}-community-files
changed_when: false
failed_when: false
register: branch_exists
Expand All @@ -28,13 +28,13 @@
gh api \
--method DELETE \
-H "Accept: application/vnd.github.v3+json" \
/repos/{{ owner }}/{{ repository_manifest.name }}/git/refs/heads/{{ community_manifest.branch }}-community-files
/repos/{{ owner }}/{{ repository_manifest.name }}/git/refs/heads/{{ community_manifest.prefix | default("") }}{{ community_manifest.branch }}-community-files
when: branch_exists.rc == 0

- name: Create working branch # noqa command-instead-of-module
ansible.builtin.shell:
cmd: >
git checkout -b {{ community_manifest.branch }}-community-files \
git checkout -b {{ community_manifest.prefix | default("") }}{{ community_manifest.branch }}-community-files \
origin/{{ community_manifest.prefix | default("") }}{{ community_manifest.branch }}
chdir: "{{ staging_path }}/{{ repository_manifest.name }}"
changed_when: true
Expand Down Expand Up @@ -65,7 +65,7 @@

- name: Push branch to remote # noqa command-instead-of-module command-instead-of-shell no-handler
ansible.builtin.shell:
cmd: "git push -u origin {{ community_manifest.branch }}-community-files"
cmd: "git push -u origin {{ community_manifest.prefix | default('') }}{{ community_manifest.branch }}-community-files"
chdir: "{{ staging_path }}/{{ repository_manifest.name }}"
when: community_copy.changed | bool

Expand Down
8 changes: 4 additions & 4 deletions ansible/roles/source-repo-sync/tasks/add_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
cmd: |
gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/{{ owner }}/{{ repository_manifest.name }}/git/ref/heads/{{ workflow_manifest.branch }}-workflows
/repos/{{ owner }}/{{ repository_manifest.name }}/git/ref/heads/{{ workflow_manifest.prefix | default("") }}{{ workflow_manifest.branch }}-workflows
changed_when: false
failed_when: false
register: working_branch_exists
Expand All @@ -28,13 +28,13 @@
gh api \
--method DELETE \
-H "Accept: application/vnd.github.v3+json" \
/repos/{{ owner }}/{{ repository_manifest.name }}/git/refs/heads/{{ workflow_manifest.branch }}-workflows
/repos/{{ owner }}/{{ repository_manifest.name }}/git/refs/heads/{{ workflow_manifest.prefix | default("") }}{{ workflow_manifest.branch }}-workflows
when: working_branch_exists.rc == 0

- name: Create working branch # noqa command-instead-of-module
ansible.builtin.shell:
cmd: >
git checkout -b {{ workflow_manifest.branch }}-workflows \
git checkout -b {{ workflow_manifest.prefix | default("") }}{{ workflow_manifest.branch }}-workflows \
origin/{{ workflow_manifest.prefix | default("") }}{{ workflow_manifest.branch }}
chdir: "{{ staging_path }}/{{ repository_manifest.name }}"
changed_when: true
Expand Down Expand Up @@ -84,7 +84,7 @@

- name: Push branch to remote # noqa command-instead-of-module command-instead-of-shell no-handler
ansible.builtin.shell:
cmd: "git push -u origin {{ workflow_manifest.branch }}-workflows"
cmd: "git push -u origin {{ workflow_manifest.prefix | default('') }}{{ workflow_manifest.branch }}-workflows"
chdir: "{{ staging_path }}/{{ repository_manifest.name }}"
changed_when: true

Expand Down
Loading