Skip to content
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

GitHub actions Update - Monitoring Configmap generation #272

Closed
wants to merge 28 commits into from
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bcfa3c2
initial updates for Monitoring Configmap
mikemcd3912 May 9, 2024
749df4b
Test Push
mikemcd3912 May 9, 2024
a88f8f4
Merge pull request #40 from mikemcd3912/mergetest
mikemcd3912 May 9, 2024
3004e7d
Missing parenthesis
mikemcd3912 May 9, 2024
f72da87
Merge branch 'githubActions' of https://github.com/mikemcd3912/eks-an…
mikemcd3912 May 9, 2024
9272858
Remove Test Partner
mikemcd3912 May 9, 2024
c832c05
Tester
mikemcd3912 May 9, 2024
0072861
Merge pull request #41 from mikemcd3912/merge2
mikemcd3912 May 9, 2024
36b0236
Delete test Partner 2 Files
mikemcd3912 May 9, 2024
280bd60
Re-use Open PR method
mikemcd3912 May 9, 2024
33535c3
test3
mikemcd3912 May 9, 2024
ee12b93
Merge pull request #42 from mikemcd3912/merge3
mikemcd3912 May 9, 2024
a52310a
Update method to re-use OpenPR logic
mikemcd3912 May 9, 2024
86aa525
Merge branch 'githubActions' of https://github.com/mikemcd3912/eks-an…
mikemcd3912 May 9, 2024
5654905
Delete Tester files
mikemcd3912 May 9, 2024
48d5ea3
Merge4
mikemcd3912 May 9, 2024
4a714f5
Merge pull request #43 from mikemcd3912/merge4
mikemcd3912 May 9, 2024
e7767a0
Remove prior test and update ConfigMap data
mikemcd3912 May 9, 2024
3733f47
Merge5
mikemcd3912 May 9, 2024
d6f3807
Merge pull request #44 from mikemcd3912/merge5
mikemcd3912 May 9, 2024
41d52b9
Fix naming of Monitoring ConfigMap
mikemcd3912 May 9, 2024
c177a2c
Test6
mikemcd3912 May 9, 2024
ac407d0
Merge pull request #45 from mikemcd3912/merge6
mikemcd3912 May 9, 2024
408d6e7
Delete Test 6 Files
mikemcd3912 May 10, 2024
9981070
Merge Demo
mikemcd3912 May 10, 2024
98921a8
Merge pull request #46 from mikemcd3912/merge-demo
mikemcd3912 May 10, 2024
8ed5d65
Remove Merge Demo files
May 20, 2024
309b5c5
Re-direct Branch targets
May 20, 2024
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
70 changes: 68 additions & 2 deletions .github/workflows/close-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ jobs:
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr

- name: Remove Deleted Files, copy over added or modified files in accepted PR
id: find-namespace-yaml
id: update-branch-with-pr-files
run: |
# Pull file information down into a JSON array
readarray -t files < <(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | jq -c '.[]')

# Checkout and update Developer branch
# Move updated files over to dev branch
git fetch --all
git config --local user.email "dev@null"
git config --local user.name "Conformitron Bot"
Expand Down Expand Up @@ -83,6 +83,72 @@ jobs:
fi
done


# Create Monitoring ConfigMap for each file's partner folder
for item in "${files[@]}"; do
status=$(echo "$item" | jq -r '.status')
filename=$(echo "$item" | jq -r '.filename')
echo $filename


if [ "$status" != removed ] && [[ $filename != *README.md ]]; then
# Parse namespace data
subdirectory=$(dirname $filename)
namespace_file_subdirectory=$(dirname $filename)
namespace_file=$(find $namespace_file_subdirectory -name *namespace*)
namespace_name=""
partner_name=""

# get namespace from dev branch partner directory. If in Testers directory, re-align to Addons/Partner/{partner}
while [ -z "$(find $namespace_file_subdirectory -name '*namespace*')" ] && [[ -z $namespace_name ]]; do
partner_name=$(basename $namespace_file_subdirectory)
namespace_file_subdirectory=$(dirname $namespace_file_subdirectory)
if [ $(basename $namespace_file_subdirectory) == "Testers" ]; then
namespace_file_subdirectory=$(dirname $namespace_file_subdirectory)
namespace_file_subdirectory=$namespace_file_subdirectory/Addons/Partner/$partner_name
elif [ $(basename $namespace_file_subdirectory) == "Partner" ] || [ $(basename $namespace_file_subdirectory) == "Core" ]; then
echo "No Namespace File Found in Partner Directory"
exit 200
fi
namespace_file=$(find $namespace_file_subdirectory -name "*namespace*")
done

if [ -f $namespace_file ]; then
namespace_file_subdirectory=$(dirname $namespace_file)
namespace_name=$(grep -E '^\s*metadata:\s*$|^\s*name:\s*' "$namespace_file" | awk -F':' '{gsub(/ /, "", $2); print $2}')
else
echo "No Namespace file found"
exit 200
fi

if [[ -n $namespace_name ]]; then
namespace=$(echo $namespace_name | xargs echo -n)
config_map_file="config-map-$namespace.yml"
echo "apiVersion: v1" >> $config_map_file
echo "kind: ConfigMap" >> $config_map_file
echo "metadata:" >> $config_map_file
echo " name: $namespace-observation-configmap" >> $config_map_file
echo " namespace: $namespace" >> $config_map_file
echo " labels:" >> $config_map_file
echo " bot: conformitron" >> $config_map_file
echo "data:" >> $config_map_file
echo " Namespace: ${namespace}" >> $config_map_file
echo " lastApprovedPrNumber: \"${{ github.event.pull_request.number }}\"" >> $config_map_file
echo " lastPrCommitHash: ${{ github.event.pull_request.head.sha }}" >> $config_map_file
echo " lastPointOfContact: ${{ github.event.pull_request.user.login }}" >> $config_map_file
echo " approved: \"$(date +%s)\"" >> $config_map_file
echo " env: $(echo $subdirectory | cut -f1 -d/ | awk -F- '{print $NF}' )" >> $config_map_file
mkdir -p ./$namespace_file_subdirectory/
mv "$config_map_file" ./$namespace_file_subdirectory/
git add ./$namespace_file_subdirectory/

else
echo "No Namespace found, Invalid namespace file"
exit 100
fi
fi
done

git commit -m "Adding new and changed files for merged PR_${{ github.event.pull_request.number }}"
git push

Loading