-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into OPS-5193-kubernetes-update-1-26
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |