Skip to content

Commit

Permalink
Merge branch 'master' into OPS-5193-kubernetes-update-1-26
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickEvers authored Dec 20, 2023
2 parents c3d122b + 63e3b1e commit 761e1ad
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ansible-count-hosts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Count Ansible hosts

on:
workflow_call:
inputs:
inventory_file:
type: string
description: "Relative path to the inventory file in the repository"
required: true
limit:
type: string
description: "Ansible limit that will have its hosts counted"
required: true
requirements_file:
type: string
description: "Relative path to the requirements file containing the Ansible version"
default: requirements.txt
outputs:
count:
value: ${{ jobs.job.outputs.count }}

jobs:
job:
runs-on: ubuntu-latest
outputs:
count: ${{ steps.count_hosts.outputs.count }}
steps:
- uses: actions/checkout@v4
- name: Count hosts in limit
id: count_hosts
run: |
# Only keep Ansible in the pip requirements
pip3 install $(grep ansible $GITHUB_WORKSPACE/${{ inputs.requirements_file }})
echo "count=$(ansible-inventory -i $GITHUB_WORKSPACE/${{ inputs.inventory_file }} --list -l ${{ inputs.limit }} | jq -e '._meta.hostvars | keys | length')" >> $GITHUB_OUTPUT
28 changes: 28 additions & 0 deletions .github/workflows/filter-branch-name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Filter branch name for ticket and scope

on:
workflow_call:
inputs:
branch_name:
description: "Branch name to filter"
required: true
type: string
outputs:
ticket:
value: ${{ jobs.job.outputs.ticket }}
scope:
value: ${{ jobs.job.outputs.scope }}

jobs:
job:
runs-on: ubuntu-latest
outputs:
ticket: ${{ steps.step.outputs.ticket }}
scope: ${{ steps.step.outputs.scope }}
steps:
- name: Filter branch name
id: step
run: |
echo "ticket=$(echo ${{ inputs.branch_name }} | grep -oE '^[a-zA-Z]+-[0-9]+')" >> $GITHUB_OUTPUT
echo "scope=$(echo ${{ inputs.branch_name }} | grep -oE '^[a-zA-Z]+-[0-9]+-[a-z]+' | grep -oE '[a-z]+$')" >> $GITHUB_OUTPUT

0 comments on commit 761e1ad

Please sign in to comment.