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

Issue 45 lsp4ij workitem 2 #16

Merged
merged 106 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
df90a4a
Added demo code to notify
vaisakhkannan Apr 29, 2024
b258f7e
Merge pull request #2 from vaisakhkannan/Issue-45-Slack-Github-Integr…
vaisakhkannan Apr 30, 2024
2ce56cb
Added code
vaisakhkannan Apr 30, 2024
3fec9df
Merge pull request #4 from vaisakhkannan/Issue-45-Slack-Github-Integr…
vaisakhkannan Apr 30, 2024
17115f2
Update main.yaml
vaisakhkannan Apr 30, 2024
ebbeabe
Update main.yaml
vaisakhkannan Apr 30, 2024
67e4ab6
Update main.yaml
vaisakhkannan Apr 30, 2024
3b53b1c
Update main.yaml
vaisakhkannan May 8, 2024
6a73414
Update main.yaml
vaisakhkannan May 8, 2024
ce1b002
Update main.yaml
vaisakhkannan May 8, 2024
7fada8d
Create lsp4ij.yaml
vaisakhkannan May 9, 2024
346bdc0
Update lsp4ij.yaml
vaisakhkannan May 9, 2024
9a68c58
Update lsp4ij.yaml
vaisakhkannan May 9, 2024
5fa53d1
Update lsp4ij.yaml
vaisakhkannan May 9, 2024
5a0ed9b
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
5aaefb8
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
205d918
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
e9d2a07
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
899ac35
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
81daa9c
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
a639546
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
34dc08e
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
ae741f9
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
9fadb58
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
2c3d3f6
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
cd46138
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
a452c56
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
b891690
Update lsp4ij.yaml
vaisakhkannan May 10, 2024
2d7a4b1
added modification
vaisakhkannan May 15, 2024
39e2966
Update lsp4ij.yaml
vaisakhkannan May 15, 2024
dde35bf
Create cicd.yaml
vaisakhkannan May 16, 2024
f276e8a
Update cicd.yaml
vaisakhkannan May 16, 2024
c437793
Update cicd.yaml
vaisakhkannan May 16, 2024
5261ab8
removed
vaisakhkannan May 16, 2024
e36b52e
Update cicd.yaml
vaisakhkannan May 17, 2024
bbc6353
Update cicd.yaml
vaisakhkannan May 17, 2024
d206d77
Update cicd.yaml
vaisakhkannan May 17, 2024
27d661f
Update cicd.yaml
vaisakhkannan May 17, 2024
406e761
Create lsp4ij-all-pr.yaml
vaisakhkannan May 17, 2024
d834f44
Update lsp4ij-all-pr.yaml
vaisakhkannan May 17, 2024
1a0b526
Update lsp4ij-all-pr.yaml
vaisakhkannan May 17, 2024
7fe8de5
Update lsp4ij-all-pr.yaml
vaisakhkannan May 17, 2024
8e59caf
Create cronjob.yaml
vaisakhkannan May 17, 2024
73a222c
Update cronjob.yaml
vaisakhkannan May 17, 2024
3448b5b
Update lsp4ij-all-pr.yaml
vaisakhkannan May 17, 2024
8d0f4c4
Update cronjob.yaml
vaisakhkannan May 17, 2024
9f6fce8
Update lsp4ij-all-pr.yaml
vaisakhkannan May 17, 2024
f641135
Update cicd.yaml
vaisakhkannan May 17, 2024
8e9e850
Update cronjob.yaml
vaisakhkannan May 17, 2024
c776211
Update cronjob.yaml
vaisakhkannan May 17, 2024
f8c0256
Update cronjob.yaml
vaisakhkannan May 17, 2024
875ef7b
Added Modification
vaisakhkannan May 20, 2024
9bb9f43
Update lsp4ij-all-pr.yaml
vaisakhkannan May 20, 2024
bc59cf3
Update lsp4ij-all-pr.yaml
vaisakhkannan May 20, 2024
59a0079
Added condition.yaml file
vaisakhkannan May 20, 2024
111f09b
Update condition.yaml
vaisakhkannan May 20, 2024
b465293
Update condition.yaml
vaisakhkannan May 20, 2024
ffb8460
Update condition.yaml
vaisakhkannan May 20, 2024
6171d07
Update condition.yaml
vaisakhkannan May 20, 2024
b73da9c
Update condition.yaml
vaisakhkannan May 20, 2024
3fb08fb
Update condition.yaml
vaisakhkannan May 20, 2024
b0fc20b
Update condition.yaml
vaisakhkannan May 20, 2024
c2381f5
Update condition.yaml
vaisakhkannan May 20, 2024
44d8300
Update condition.yaml
vaisakhkannan May 20, 2024
5ee17de
Update condition.yaml
vaisakhkannan May 20, 2024
0b3f19b
Update condition.yaml
vaisakhkannan May 20, 2024
b96d3fb
Update condition.yaml
vaisakhkannan May 20, 2024
a24ef73
Update condition.yaml
vaisakhkannan May 20, 2024
3d3d5f9
Update condition.yaml
vaisakhkannan May 20, 2024
5c490dd
Update condition.yaml
vaisakhkannan May 20, 2024
8081387
Update condition.yaml
vaisakhkannan May 20, 2024
92334ad
Update condition.yaml
vaisakhkannan May 20, 2024
275f1a8
Update condition.yaml
vaisakhkannan May 20, 2024
e23445b
Update condition.yaml
vaisakhkannan May 20, 2024
ff77dfa
Update condition.yaml
vaisakhkannan May 20, 2024
9e6520c
Update condition.yaml
vaisakhkannan May 20, 2024
ec69013
Update condition.yaml
vaisakhkannan May 20, 2024
5d7a789
Update condition.yaml
vaisakhkannan May 20, 2024
4427ccd
Update condition.yaml
vaisakhkannan May 20, 2024
0503858
Update condition.yaml
vaisakhkannan May 20, 2024
849c248
Update condition.yaml
vaisakhkannan May 20, 2024
7d606b7
Update condition.yaml
vaisakhkannan May 20, 2024
85da09c
Update condition.yaml
vaisakhkannan May 20, 2024
5772156
Update condition.yaml
vaisakhkannan May 20, 2024
b81afb0
Update condition.yaml
vaisakhkannan May 20, 2024
7d1f2b7
Update condition.yaml
vaisakhkannan May 20, 2024
fb5efc8
Update condition.yaml
vaisakhkannan May 20, 2024
e43c18c
Update condition.yaml
vaisakhkannan May 20, 2024
b10204b
Update condition.yaml
vaisakhkannan May 20, 2024
2e79242
Update condition.yaml
vaisakhkannan May 20, 2024
5ccc347
Update condition.yaml
vaisakhkannan May 20, 2024
5dc64c8
Update condition.yaml
vaisakhkannan May 20, 2024
7e60c85
Update condition.yaml
vaisakhkannan May 20, 2024
75879e2
Update condition.yaml
vaisakhkannan May 20, 2024
b2130a2
Update condition.yaml
vaisakhkannan May 20, 2024
eb56f40
Update condition.yaml
vaisakhkannan May 20, 2024
efa7d8f
Update condition.yaml
vaisakhkannan May 20, 2024
396138b
Update condition.yaml
vaisakhkannan May 20, 2024
35686b7
Update condition.yaml
vaisakhkannan May 20, 2024
3971adc
Update condition.yaml
vaisakhkannan May 20, 2024
1d4da3a
Merge branch 'main' into Issue-45-Lsp4ij-Workitem-2
vaisakhkannan May 22, 2024
7fdae67
Update cronjob.yaml
vaisakhkannan May 22, 2024
04febc9
added
vaisakhkannan May 22, 2024
2d7238b
Update condition.yaml
vaisakhkannan May 22, 2024
da95174
Update condition.yaml
vaisakhkannan May 22, 2024
cd75ccf
Update condition.yaml
vaisakhkannan May 22, 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
147 changes: 147 additions & 0 deletions .github/workflows/condition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Fetch All Open Pull Requests using condition

on:
workflow_dispatch:
push:
branches: '**'
pull_request:
branches: [ main, code-action-unification, issue-45-main ]

jobs:
fetch_all_pull_requests_and_notify_using_condition:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Restore cache
id: cache-restore
uses: actions/cache@v2
with:
path: cache
key: ${{ runner.os }}-pr-cache-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-pr-cache

- name: Check if cache restored
run: |
if [ -f cache/notified_prs.json ]; then
echo "Cache restored successfully."
cat cache/notified_prs.json
else
echo "Cache not restored or file does not exist."
fi

- name: Fetch all opened pull request details using condition
id: fetch_all_pull_requests_using_condition
run: |
mkdir -p cache

pr_infos=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/vaisakhkannan/liberty-tools-intellij/pulls?state=open&sort=created&direction=desc&per_page=100")

echo "API Data ------$pr_infos"

# Load previous PR data if exists
if [ -f cache/notified_prs.json ]; then
previous_prs=$(cat cache/notified_prs.json)
echo "Previous PRs -------$previous_prs"
else
previous_prs="[]"
fi

pr_list=""
new_notified_prs="[]"
notify=false

for pr_info in $(echo "$pr_infos" | jq -r '.[] | @base64'); do
_jq() {
echo "$pr_info" | base64 --decode | jq -r "${1}"
}

pr_number=$(_jq '.number')
pr_title=$(_jq '.title')
pr_user=$(_jq '.user.login')
pr_url=$(_jq '.html_url')
pr_draft=$(_jq '.draft')
pr_created_at=$(_jq '.created_at')
pr_updated_at=$(_jq '.updated_at')

pr_data=$(jq -n --arg number "$pr_number" --arg updated_at "$pr_updated_at" '{number: $number, updated_at: $updated_at}')
new_notified_prs=$(echo "$new_notified_prs" | jq --argjson pr_data "$pr_data" '. += [$pr_data]')

echo "Whole PR data ------- $pr_data"
echo "New Notified PR List------ $new_notified_prs"

# Check if the PR is new or updated
previous_pr=$(echo "$previous_prs" | jq --arg number "$pr_number" '.[] | select(.number == $number)')
echo "Checking PR is new or not --- $previous_pr"
if [ -z "$previous_pr" ] || [ "$(echo "$previous_pr" | jq -r '.updated_at')" != "$pr_updated_at" ]; then
pr_list="${pr_list}\n*Pull Request* #${pr_number}: ${pr_title}\n*Created by*: ${pr_user}\n*URL*: ${pr_url}\n*Draft*: ${pr_draft}\n*Created At*: ${pr_created_at}\n*Last Updated At*: ${pr_updated_at}\n"
echo "New PR List ------- $pr_list"
notify=true
echo "Boolean Value for notify ------- $notify"
fi
done

# Save current PR data for future comparison
echo "$new_notified_prs" > cache/notified_prs.json
echo "Latest Modified ------"
cat cache/notified_prs.json # Ensure the JSON file is updated and print its content for debugging

if [ "$notify" = true ]; then
echo -e "$pr_list" > pr_list.txt
echo "::set-output name=notify::true"
else
echo "::set-output name=notify::false"
fi

- name: Debug Notify Value
run: |
echo "Notify value: ${{ steps.fetch_all_pull_requests_using_condition.outputs.notify }}"

- name: Send Slack notification
if: success() && steps.fetch_all_pull_requests_using_condition.outputs.notify == 'true'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
echo "Condition value ------: ${{ steps.fetch_all_pull_requests_using_condition.outputs.notify }}"
pr_list=$(cat pr_list.txt)
payload=$(cat <<-EOF
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "List of Open Pull Requests using condition latest 4"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${pr_list}"
}
}
]
}
EOF
)
echo "$payload" # Debugging: Print payload to verify its formatt
curl -X POST -H 'Content-type: application/json' --data "$payload" $SLACK_WEBHOOK_URL || echo "Slack notification failed with status code: $?"

- name: Save cache
if: always()
uses: actions/cache@v2
with:
path: cache
key: ${{ runner.os }}-pr-cache-${{ github.run_id }}

- name: Verify Cache Save
if: always()
run: |
echo "Checking saved cache content..."
ls -l cache/
cat cache/notified_prs.json
67 changes: 67 additions & 0 deletions .github/workflows/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Cron Job to List All Open Pull Requests

on:
schedule:
- cron: '30 6 * * 1-5'

jobs:
fetch_all_pull_requests_and_notify_cron_job:
runs-on: ubuntu-latest

steps:
- name: Fetch all opened pull request details using cron jobs
shell: bash
id: fetch_all_pull_requests_using_cron
run: |
pr_infos=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/redhat-developer/lsp4ij/pulls?state=open&sort=created&direction=desc&per_page=100")

pr_list=""
for pr_info in $(echo "$pr_infos" | jq -r '.[] | @base64'); do
_jq() {
echo "$pr_info" | base64 --decode | jq -r "${1}"
}

pr_number=$(_jq '.number')
pr_title=$(_jq '.title')
pr_user=$(_jq '.user.login')
pr_url=$(_jq '.html_url')
pr_draft=$(_jq '.draft')
pr_created_at=$(_jq '.created_at')
pr_updated_at=$(_jq '.updated_at')

pr_list="${pr_list}\n*Pull Request* #${pr_number}: ${pr_title}\n*Created by*: ${pr_user}\n*URL*: ${pr_url}\n*Draft*: ${pr_draft}\n*Created At*: ${pr_created_at}\n*Last Updated At*: ${pr_updated_at}\n"
done

echo -e "$pr_list" > pr_list.txt
cat pr_list.txt

- name: Send Slack notification
if: success()
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
pr_list=$(cat pr_list.txt)
payload=$(cat <<-EOF
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "List of Open Pull Requests using Cron Jobs"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${pr_list}"
}
}
]
}
EOF
)
echo "$payload"
curl -X POST -H 'Content-type: application/json' --data "$payload" $SLACK_WEBHOOK_URL
70 changes: 70 additions & 0 deletions .github/workflows/lsp4ij-all-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Fetch All Open Pull Requests

on:
workflow_dispatch:
push:
branches: '**'
pull_request:
branches: [ main, code-action-unification, issue-45-main ]

jobs:
fetch_all_pull_requests_and_notify:
runs-on: ubuntu-latest

steps:
- name: Fetch all opened pull request details
shell: bash
id: fetch_all_pull_requests
run: |
pr_infos=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/redhat-developer/lsp4ij/pulls?state=open&sort=created&direction=desc&per_page=100")

pr_list=""
for pr_info in $(echo "$pr_infos" | jq -r '.[] | @base64'); do
_jq() {
echo "$pr_info" | base64 --decode | jq -r "${1}"
}

pr_number=$(_jq '.number')
pr_title=$(_jq '.title')
pr_user=$(_jq '.user.login')
pr_url=$(_jq '.html_url')
pr_draft=$(_jq '.draft')
pr_created_at=$(_jq '.created_at')
pr_updated_at=$(_jq '.updated_at')

pr_list="${pr_list}\n*Pull Request* #${pr_number}: ${pr_title}\n*Created by*: ${pr_user}\n*URL*: ${pr_url}\n*Draft*: ${pr_draft}\n*Created At*: ${pr_created_at}\n*Last Updated At*: ${pr_updated_at}\n"
done

echo -e "$pr_list" > pr_list.txt
cat pr_list.txt

- name: Send Slack notification
if: success()
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
pr_list=$(cat pr_list.txt)
payload=$(cat <<-EOF
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "List of Open Pull Requests"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${pr_list}"
}
}
]
}
EOF
)
echo "$payload"
curl -X POST -H 'Content-type: application/json' --data "$payload" $SLACK_WEBHOOK_URL
Loading