Skip to content

Commit 4a3cbed

Browse files
author
github-actions
committed
Merge changes from stage to main branch (PR #61).
1 parent 94c77af commit 4a3cbed

File tree

982 files changed

+291798
-30070
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

982 files changed

+291798
-30070
lines changed

.ansible-lint

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ exclude_paths:
55
- .cache/
66
- .github/
77
#- docs/
8-
#- roles/sap_vm_provision
8+
# Ansible requirements are not recognized as valid yaml file
9+
- deploy_scenarios/.*/ansible_requirements\.yml$
10+
- common_fragments/vars/ansible_requirements.yml
911

1012
enable_list:
1113
- yaml
@@ -32,7 +34,7 @@ skip_list:
3234
# Used for /etc/hosts edits
3335
- no-tabs
3436

35-
# Incorrectly shows error for nested {%- endfor -%} already correct idententation
37+
# Incorrectly shows error for nested {%- endfor -%} already correct indent
3638
- jinja[spacing]
3739

3840
# Shell commands are required
@@ -45,7 +47,7 @@ skip_list:
4547
- yaml[empty-lines]
4648

4749
# Ignore ha_cluster vars used within sap_ha_pacemaker_cluster
48-
- var-naming[no-role-prefix]
50+
# - var-naming[no-role-prefix]
4951

5052
# Ignore dynamic variable population for Scale-Out
5153
- var-naming[no-jinja]

.github/workflows/ansible-lint.yml

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
---
22

3-
# Workflow for ansible-lint of the collection
4-
5-
name: ansible-lint of all Ansible Playbooks for SAP
3+
name: ansible-lint of the ansible playbooks for sap
64

75
on:
6+
# Runs at 10:10 on every Monday
87
schedule:
98
- cron: '10 10 * * 1'
109

10+
# Runs on push to dev and main branches
11+
push:
12+
branches:
13+
- dev
14+
- main
15+
16+
# Enable manual start button
1117
workflow_dispatch:
1218

1319
jobs:
@@ -17,6 +23,8 @@ jobs:
1723
steps:
1824
- name: Check out the code
1925
uses: actions/checkout@v4
26+
with:
27+
path: repo_playbooks
2028

2129
- name: Set up Python 3
2230
uses: actions/setup-python@v5
@@ -25,14 +33,39 @@ jobs:
2533

2634
- name: Install dependencies for Python
2735
run: |
28-
pip3 install ansible==9.1.0
29-
pip3 install ansible-compat==4.1.10
30-
pip3 install ansible-core==2.16.2
31-
pip3 install ansible-lint==6.22.1
36+
pip3 install --upgrade pip
37+
pip3 install ansible==11.4.0
38+
pip3 install ansible-compat==4.1.11
39+
pip3 install ansible-core==2.18.4
40+
pip3 install ansible-lint==25.2.1
3241
33-
- name: Install dependencies for Ansible
34-
run: ansible-galaxy collection install -r /home/runner/work/ansible.playbooks_for_sap/ansible.playbooks_for_sap/deploy_scenarios/sap_hana/ansible_requirements.yml
42+
# dev branch is using shared fragments
43+
- name: Install dependencies for Ansible (dev)
44+
working-directory: repo_playbooks
45+
if: github.ref == 'refs/heads/dev'
46+
run: |
47+
ansible-galaxy collection install -r ./common_fragments/ansible_requirements.yml
48+
49+
# main branch is using:
50+
# - deploy_scenarios/sap_hana if file exists
51+
# - else first scenario with ansible_requirements.yml
52+
- name: Install dependencies for Ansible (main)
53+
working-directory: repo_playbooks
54+
if: github.ref == 'refs/heads/main'
55+
run: |
56+
if [ -f ./deploy_scenarios/sap_hana/ansible_requirements.yml ]; then
57+
ansible-galaxy collection install -r ./deploy_scenarios/sap_hana/ansible_requirements.yml
58+
else
59+
first_file=$(find ./deploy_scenarios/ -name ansible_requirements.yml -print -quit)
60+
if [ -n "$first_file" ]; then
61+
echo "Using $first_file"
62+
ansible-galaxy collection install -r "$first_file"
63+
else
64+
echo "No ansible_requirements.yml found in deploy_scenarios"
65+
exit 1
66+
fi
67+
fi
3568
3669
- name: Run ansible-lint
37-
working-directory: /home/runner/work/ansible.playbooks_for_sap/
70+
working-directory: repo_playbooks
3871
run: ansible-lint

.github/workflows/ansible_software_availability.yml

Lines changed: 0 additions & 280 deletions
This file was deleted.

.github/workflows/codespell.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1+
---
12
name: CodeSpell
23

34
on:
5+
# Runs on push and pull request to dev
46
push:
57
branches:
68
- dev
79
pull_request:
810
branches:
911
- dev
1012

13+
# Enable manual start button
14+
workflow_dispatch:
15+
1116
jobs:
1217
codespell:
1318
name: Check for spelling errors
1419
runs-on: ubuntu-latest
1520

1621
steps:
17-
- uses: actions/checkout@v4
22+
- name: Check out the code
23+
uses: actions/checkout@v4
24+
with:
25+
path: repo_playbooks
26+
1827
- uses: codespell-project/actions-codespell@v2
1928
with:
29+
path: repo_playbooks
2030
# lowercase only
2131
ignore_words_list: aas,iterm,daa
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
---
2+
name: Publish Stage branch to Main
3+
4+
on:
5+
# Runs on merged pull_request: to stage branch
6+
pull_request:
7+
branches:
8+
- stage
9+
types:
10+
- closed
11+
12+
# Enable manual start button
13+
workflow_dispatch:
14+
15+
jobs:
16+
sync:
17+
name: 'Publish Stage branch to Main'
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout branch stage
22+
uses: actions/checkout@v4
23+
with:
24+
path: repo_playbooks_stage
25+
ref: stage
26+
27+
- name: Checkout branch main
28+
uses: actions/checkout@v4
29+
with:
30+
path: repo_playbooks_main
31+
ref: main
32+
33+
- name: Remove internal scenarios from publishing
34+
working-directory: repo_playbooks_stage
35+
run: |
36+
shopt -s nullglob # Ensures that empty glob results are empty
37+
38+
# Loop through all deploy_scenarios and supported special_actions
39+
for dir in ./deploy_scenarios/* ./special_actions/*; do
40+
extravars_file="$dir/ansible_extravars.yml"
41+
42+
# Check if the ansible_extravars.yml file exists
43+
if [ -f "$extravars_file" ]; then
44+
# Check if the file contains "sap_playbook_internal: true"
45+
if grep -q "sap_playbook_internal: true" "$extravars_file"; then
46+
rm -rf "$dir"
47+
fi # string is present
48+
fi # extravars file exists
49+
done
50+
51+
shopt -u nullglob # Revert nullglob to its default behavior
52+
53+
- name: Copy shared files to scenarios
54+
working-directory: repo_playbooks_stage
55+
run: |
56+
shopt -s nullglob # Ensures that empty results are empty
57+
58+
# Update path in interactive tasks
59+
sed -i 's/..\/..\/common_fragments\/tasks\//optional\//' ./common_fragments/tasks/interactive/*.yml ./common_fragments/tasks/interactive/*/*.yml
60+
61+
# Loop through all deploy_scenarios and supported special_actions
62+
for dir in ./deploy_scenarios/* ./special_actions/*; do
63+
# Copy interactive tasks only if optional/ansible_extravars_interactive.yml is present.
64+
interactive_vars="$dir"/optional/ansible_extravars_interactive.yml
65+
if [ -f "$interactive_vars" ]; then
66+
# Copy tasks
67+
cp -r ./common_fragments/tasks/* $dir/optional/
68+
69+
# Update path to interactive tasks in playbooks
70+
sed -i 's/..\/..\/common_fragments\/tasks\//optional\//' $dir/ansible_playbook.yml
71+
fi # interactive_vars exists
72+
73+
# Copy ansible_requirements if it does not exist
74+
ansible_requirements="$dir"/ansible_requirements.yml
75+
if [ ! -f "$ansible_requirements" ]; then
76+
cp ./common_fragments/ansible_requirements.yml $dir/
77+
fi # ansible_requirements not exists
78+
done
79+
80+
shopt -u nullglob
81+
82+
- name: Append shared fragments to deploy_scenarios files
83+
working-directory: repo_playbooks_stage
84+
run: |
85+
# Loop through all deploy_scenarios and supported special_actions
86+
for dir in ./deploy_scenarios/* ./special_actions/*; do
87+
88+
# Loop through all valid extravars files
89+
for file in "$dir"/ansible_extravars_*_base.yml; do
90+
if [[ -f "$file" ]]; then
91+
# Extract platform name using basename of file
92+
platform=$(basename "$file" | sed 's/ansible_extravars_\(.*\)_base\.yml/\1/')
93+
94+
# Define files for appending
95+
fragment_vars="common_fragments/vars/platform_vars_${platform}.yml"
96+
fragment_images="common_fragments/vars/platform_images_${platform}.yml"
97+
scenario_spec="$dir"/ansible_extravars_"$platform"_spec.yml
98+
interactive_vars="$dir"/optional/ansible_extravars_interactive.yml
99+
100+
# Append shared platform vars fragment when it exists
101+
if [ -f "$fragment_vars" ]; then
102+
sed 's/^---/\n/g' "$fragment_vars" >> "$file"
103+
fi # if fragment_vars exists
104+
105+
# Append scenario spec vars when it exists
106+
# Spec is also appended to interactive vars
107+
if [ -f "$scenario_spec" ]; then
108+
sed 's/^---/\n/g' "$scenario_spec" >> "$file"
109+
if [ -f "$interactive_vars" ]; then
110+
sed 's/^---/\n/g' "$scenario_spec" >> "$interactive_vars"
111+
fi # interactive_vars exists
112+
rm -f "$scenario_spec"
113+
fi # if scenario_spec exists
114+
115+
# Append shared platform image fragment when it exists
116+
# Images are also appended to interactive vars
117+
if [ -f "$fragment_images" ]; then
118+
sed 's/^---/\n/g' "$fragment_images" >> "$file"
119+
if [ -f "$interactive_vars" ]; then
120+
sed 's/^---/\n/g' "$fragment_images" >> "$interactive_vars"
121+
fi # interactive_vars exists
122+
fi # if fragment_images exists
123+
124+
# Remove base files
125+
new_file="${file%_base.yml}.yml"
126+
mv "$file" "$new_file"
127+
fi # if file exists
128+
129+
done # file loop
130+
done # dir loop
131+
132+
# Remove fragments after copying them
133+
git rm -rf ./common_fragments
134+
135+
- name: Synchronize main with transformed stage
136+
run: |
137+
rsync --archive --delete --exclude '.git' repo_playbooks_stage/ repo_playbooks_main/
138+
139+
140+
- name: Check for changes
141+
working-directory: repo_playbooks_main
142+
id: check_changes
143+
run: |
144+
git add .
145+
if [[ -n "$(git status --porcelain)" ]]; then
146+
echo "::set-output name=has_changes::true"
147+
else
148+
echo "::set-output name=has_changes::false"
149+
fi
150+
151+
- name: Commit changes
152+
working-directory: repo_playbooks_main
153+
if: steps.check_changes.outputs.has_changes == 'true'
154+
run: |
155+
git config user.name github-actions
156+
git config user.email github-actions@github.com
157+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
158+
PR_NUMBER=$(echo ${{ github.event.pull_request.number }})
159+
else
160+
PR_NUMBER="manual"
161+
fi
162+
git commit -m "Merge changes from stage to main branch (PR #$PR_NUMBER)."
163+
164+
- name: Push changes
165+
working-directory: repo_playbooks_main
166+
if: steps.check_changes.outputs.has_changes == 'true'
167+
run: |
168+
git push origin main --force

0 commit comments

Comments
 (0)