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 #267

Merged
merged 29 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2b524fb
Actions Updates
mikemcd3912 May 1, 2024
2e406e1
Comments on new function
mikemcd3912 May 1, 2024
265ebc5
GH Actions work
mikemcd3912 May 1, 2024
7554743
Revert "GH Actions work"
mikemcd3912 May 1, 2024
d113e18
Set targets for development
mikemcd3912 May 1, 2024
31b1358
Commit 1
mikemcd3912 May 1, 2024
e1a1ad0
Sync
mikemcd3912 May 1, 2024
bd1530e
Update commit list iteration
mikemcd3912 May 1, 2024
5c999ba
Merge pull request #33 from mikemcd3912/multi-commit
mikemcd3912 May 1, 2024
d61e877
Revert "Multi commit"
mikemcd3912 May 1, 2024
f774d80
Merge pull request #34 from mikemcd3912/revert-33-multi-commit
mikemcd3912 May 1, 2024
9d73e40
Add dependancy
mikemcd3912 May 1, 2024
12f7d34
Commit 1
mikemcd3912 May 1, 2024
f327e0b
Commit 2
mikemcd3912 May 1, 2024
294af94
Merge pull request #35 from mikemcd3912/multi-commit-merge
mikemcd3912 May 1, 2024
0b3fe67
Job naming correction
mikemcd3912 May 1, 2024
39eb626
Removing Merged PR Files
mikemcd3912 May 1, 2024
cbe6ea6
Internal updates
mikemcd3912 May 1, 2024
790ed96
Fix paths ignore
mikemcd3912 May 1, 2024
ddf9a19
Merge pull request #38 from mikemcd3912/internal-update-merge
mikemcd3912 May 1, 2024
afc1799
Remove merged test PR files
mikemcd3912 May 1, 2024
81ab912
Testers Search update
mikemcd3912 May 3, 2024
dcd8c58
new tester File
mikemcd3912 May 3, 2024
2b72b26
Sync
mikemcd3912 May 3, 2024
fe7d4b7
Merge pull request #39 from mikemcd3912/partner-merge-sync-test
mikemcd3912 May 3, 2024
d6333e3
Remove Merged PR39
mikemcd3912 May 3, 2024
dfb7f82
Delay adjustment from 120 to 60
mikemcd3912 May 3, 2024
37a8167
Fix newrelic version variance
mikemcd3912 May 3, 2024
12dd7a8
Re-direct branch target for merge
mikemcd3912 May 3, 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
72 changes: 62 additions & 10 deletions .github/workflows/close-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ on:
pull_request_target:
branches: [main]
types: [closed]
paths-ignore:
- 'Validated_Partners/**'
- '.github/**'
- 'docs'
- '.git'

jobs:
merge-master-back-to-dev:
if: github.event.pull_request.merged == false

# All Closed branches reverse commits made by the open/reopen/sync GH Action
revert-testing-commit:
timeout-minutes: 2
runs-on: ubuntu-latest
steps:
Expand All @@ -23,14 +19,70 @@ jobs:
run: |
# Get Commits from this PR
TAG=PR_${{ github.event.pull_request.number }}
commits=$(git rev-list HEAD --grep=$TAG --max-count=1)
echo "commits: $commits"

# Revert Commits or Log that no change was made
git config --local user.email "dev@null"
git config --local user.name "Conformitron Bot"

git revert $commits --no-edit || echo "Commit $commits not reverted"
for commit in $(git rev-list HEAD --grep=$TAG); do
echo $commit
git revert $commit --no-edit || echo "Commit $commit not reverted"
done

git push

# Accepted PR's apply merged changes
commit-accepted-pr-files:
if: github.event.pull_request.merged == true
needs: revert-testing-commit
timeout-minutes: 2
runs-on: ubuntu-latest
steps:
- name: Checkout Base
uses: actions/checkout@v4

- name: Checkout PR Code
run:
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
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
git fetch --all
git config --local user.email "dev@null"
git config --local user.name "Conformitron Bot"
# fetch most recent update to dev
git checkout developer_branch
git pull

# Remove Deleted Files, copy over added or modified files
for item in "${files[@]}"; do
status=$(echo "$item" | jq -r '.status')
filename=$(echo "$item" | jq -r '.filename')

if [ "$status" == renamed ]; then
git checkout pr -- $filename
git add $filename
if [ -f $(echo "$item" | jq -r '.previous_filename') ]; then
git rm $(echo "$item" | jq -r '.previous_filename')
fi
echo "Renaming $filename"
elif [ "$status" != removed ]; then
git checkout pr -- $filename
git add $filename
echo "Moving $filename"
else
if [ -f $filename ]; then
echo "Deleting $filename"
git rm $filename
fi
fi
done

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

19 changes: 10 additions & 9 deletions .github/workflows/new-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
paths-ignore:
- 'Validated_Partners/**'
- '.github/**'
- 'docs'
- '.git'
- 'docs/**'
- '.git/**'

jobs:
build:
Expand All @@ -23,7 +23,7 @@ jobs:

- if: ${{github.event.action == 'synchronize' }}
name: Sync Pause
run: sleep 120
run: sleep 60

- name: Parse Namespace data, Create ConfigMap
id: find-namespace-yaml
Expand Down Expand Up @@ -77,22 +77,23 @@ jobs:
namespace_file_subdirectory=$(dirname $filename)
namespace_file=$(find $namespace_file_subdirectory -name *namespace*)
namespace_name=""
partner_name=""

# get namespace from dev branch partner directory
# 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_name=$(yq e 'select(document_index==0).metadata.namespace' $filename)
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 [[ -n $namespace_name ]]; then
namespace_file_subdirectory=$(dirname $filename)
elif [ -f $namespace_file ]; then
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
Expand Down Expand Up @@ -127,5 +128,5 @@ jobs:
fi
done

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