Skip to content

Commit

Permalink
chore: try with new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AntBush committed Sep 23, 2024
1 parent 88970c6 commit a4b38ae
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions .github/workflows/move-on-merge-conflict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Check Merge Conflicts and Update Jira

on:
workflow_call:
secrets:
JIRA_AUTH: { required: true }
GITHUB_TOKEN: { required: true }
push:

jobs:
Expand All @@ -18,22 +21,34 @@ jobs:

- name: Get branches to process
id: get_branches
run: |
echo "No branches provided as input, fetching branches starting with NDT"
git fetch --all
branches=$(git branch -r | grep 'origin/NDT' | sed 's|origin/||' | xargs)
if [ -z "$branches" ]; then
echo "No branches starting with 'NDT' found."
echo "branches=[]" >> $GITHUB_OUTPUT
exit 0
fi
branches_json=$(printf '%s\n' $branches | jq -R . | jq -s .)
echo "Branches to process: $branches_json"
echo "branches=$branches_json" >> $GITHUB_OUTPUT
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const {owner, repo } = context.repo;
const { data: pullRequests } = await github.pulls.lise({
owner,
repo,
state: 'open',
});
const branches = []
const filteredPrs = pullRequests.filter(pr => !pr.head.repo.fork && pr.head.ref.startsWith('NDT-') && !pr.draft);
for (const pr of filteredPrs) {
const prReviews = await github.pulls.listReviews({
owner,
repo,
pull_number: pr.number,
});
const approved = prReviews.data.some(review => review.state === 'APPROVED');
if(approved) {
branches.push(pr.head.ref);
}
}
return branches;
- name: Process branches
env:
BRANCHES: ${{ steps.get_branches.outputs.branches }}
BRANCHES: ${{ steps.get_branches.outputs.result }}
JIRA_AUTH: ${{ secrets.JIRA_AUTH }}
run: |
set -e
Expand Down

0 comments on commit a4b38ae

Please sign in to comment.