For one of my customers, I use Semaphore UI to build and deploy a WordPress website.
The pipeline is simple: Build → Automatic deploy to DEV → Manual deploy to PROD.
The website code and the Ansible playbooks live in separate repositories, so I use a small Ansible task to clone the website repository:
- name: Update repo from {{ website_branch_prepared }}
ansible.builtin.git:
repo: git@github.com:*****/{{ slug }}.git
force: true
accept_hostkey: true
version: "{{ website_branch_prepared }}"
dest: "{{ tmp_dir.path }}"
key_file: "{{ tmp_key_file.path }}"
register: git_info
Since the source code is stored on GitHub, I use a GitHub webhook to trigger the Build task automatically on every commit.
The GitHub webhook calls the Semaphore Integration. Semaphore supports HMAC-based GitHub webhook authentication, so the setup is straightforward.
Everything worked well except for one issue:
I needed Semaphore to build the same branch that I pushed to, without manually updating the template configuration each time.
GitHub webhooks include the branch name in the ref field, but in this format:
refs/heads/<branch_name>
Semaphore Integrations can extract this field into a variable, but they do not modify or clean up the value.
To solve this, I added a simple Ansible task that prepares the branch name:
- name: Remove 'refs/heads/' prefix from branch name
ansible.builtin.set_fact:
website_branch_prepared: "{{ website_branch | regex_replace('^refs/heads/', '') }}"
And that's it — now everything works exactly as I need!




Top comments (0)