Skip to content

Commit

Permalink
Workflow renames
Browse files Browse the repository at this point in the history
  • Loading branch information
gtjoseph committed Jun 20, 2024
1 parent ce349b9 commit 6facfd1
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 255 deletions.
187 changes: 0 additions & 187 deletions .github/workflows/MergeApproved.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: PRLabeled
run-name: "${{github.workflow}}-${{github.event.label.name}}-${{github.event.number}}"
name: PRRecheck
run-name: "PR ${{github.event.number}} PRRecheck"
on:
pull_request_target:
types: [ labeled ]
Expand All @@ -8,20 +8,9 @@ concurrency:
group: ${{github.workflow}}-${{github.event.label.name}}-${{github.event.number}}
cancel-in-progress: true

env:
PR_NUMBER: ${{ github.event.number }}
MODULES_BLACKLIST: ${{ vars.GATETEST_MODULES_BLACKLIST }} ${{ vars.UNITTEST_MODULES_BLACKLIST }}

jobs:
AsteriskCherryPickTest:
name: CherryPickTest
if: ${{ github.event.label.name == vars.CHERRY_PICK_TEST_LABEL }}
uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskCherryPickTest.yml@main
secrets:
TOKEN: ${{ secrets.GITHUB_TOKEN }}

AsteriskRecheckPR:
name: Recheck
PRCheck:
name: PRCheck
if: ${{ github.event.label.name == vars.RECHECKPR_LABEL }}
uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskUnitGateTest.yml@main
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/OnPRStateChange.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
with:
action-vars: ${{ toJSON(steps.setvars.outputs) }}

CheckPR:
name: CheckPR
PRCheck:
name: PRCheck
needs: Setup
uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskUnitGateTest.yml@main
with:
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/OnPRTestCherryPick.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: PRTestCherryPick
run-name: "PR ${{github.event.number}} PRTestCherryPick"
on:
pull_request_target:
types: [ labeled ]

concurrency:
group: ${{github.workflow}}-${{github.event.label.name}}-${{github.event.number}}
cancel-in-progress: true

jobs:
CherryPickTest:
name: CherryPickTest
if: ${{ github.event.label.name == vars.CHERRY_PICK_TEST_LABEL }}
uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskCherryPickTest.yml@main
secrets:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: PRSubmitActions
run-name: "PRSubmitActions: Test ${{github.event.action}}"
name: PRPostCheckActions
run-name: "PRPostCheckActions ${{github.event.workflow.name}} ${{github.event.action}}"
on:
workflow_run:
workflows: [PRSubmitTests]
workflows: [PRStateChanged,PRRecheck]
types:
- requested
- completed
Expand All @@ -12,26 +12,31 @@ env:
REPO: ${{ github.repository }}

jobs:
PRSubmitActions:
PRPostCheckActions:
runs-on: ubuntu-latest
outputs:
PR_NUMBER: ${{ steps.getpr.outputs.PR_NUMBER }}
steps:
- name: DumpEnvironment
uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main

- name: Get PR Number
id: getpr
uses: actions/github-script@v7
with:
retries: 5
script: |
let search = `repo:${context.repo.owner}/${context.repo.repo} ${context.payload.workflow_run.head_sha}`;
let prs = await github.rest.search.issuesAndPullRequests({
q: search,
});
if (prs.data.total_count == 0) {
core.setFailed(`Unable to get PR for ${context.payload.workflow_run.head_sha}`);
return;
}
let pr_number = prs.data.items[0].number;
core.setOutput('pr_number', pr_number);
return;
env:
GH_TOKEN: ${{ github.token }}
SHA: ${{github.event.workflow_run.head_sha}}
run: |
PR_NUMBER=$(gh -R $REPO search prs $SHA --json number --jq '.[].number')
if [ -z "$PR_NUMBER" ] ; then
echo "::error::Unable to find PR number"
exit 1
fi
if [[ "$PR_NUMBER" =~ ^[0-9]+$ ]] ; then
echo "PR_NUMBER=${PR_NUMBER}" >>${GITHUB_OUTPUT}
exit 0
fi
echo "::error::PR number '$PR_NUMBER' not valid"
exit 1
- name: Set Label
id: setlabel
Expand Down Expand Up @@ -115,35 +120,35 @@ jobs:
})
return;
- name: Add reviewers
if: github.event.action == 'completed'
uses: actions/github-script@v7
env:
PR_NUMBER: ${{steps.getpr.outputs.PR_NUMBER}}
REVIEWERS: ${{vars.PR_REVIEWERS}}
with:
retries: 5
github-token: ${{ secrets.ASTERISKTEAM_PAT }}
script: |
let rs = JSON.parse(process.env.REVIEWERS.length ? process.env.REVIEWERS : '[]');
let users = [];
let teams = [];
for (const r of rs) {
if (r.indexOf("/") > 0) {
teams.push(r.split('/')[1]);
} else {
users.push(r);
}
}
if (teams.length > 0 || users.length > 0) {
core.info(`Adding user reviewers ${users}`);
core.info(`Adding team reviewers ${teams}`);
await github.rest.pulls.requestReviewers({
pull_number: process.env.PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
reviewers: users,
team_reviewers: teams
});
}
return;
# - name: Add reviewers
# if: github.event.action == 'completed'
# uses: actions/github-script@v7
# env:
# PR_NUMBER: ${{steps.getpr.outputs.PR_NUMBER}}
# REVIEWERS: ${{vars.PR_REVIEWERS}}
# with:
# retries: 5
# github-token: ${{ secrets.ASTERISKTEAM_PAT }}
# script: |
# let rs = JSON.parse(process.env.REVIEWERS.length ? process.env.REVIEWERS : '[]');
# let users = [];
# let teams = [];
# for (const r of rs) {
# if (r.indexOf("/") > 0) {
# teams.push(r.split('/')[1]);
# } else {
# users.push(r);
# }
# }
# if (teams.length > 0 || users.length > 0) {
# core.info(`Adding user reviewers ${users}`);
# core.info(`Adding team reviewers ${teams}`);
# await github.rest.pulls.requestReviewers({
# pull_number: process.env.PR_NUMBER,
# owner: context.repo.owner,
# repo: context.repo.repo,
# reviewers: users,
# team_reviewers: teams
# });
# }
# return;
19 changes: 19 additions & 0 deletions .github/workflows/onPRMergeApproved.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: PRMergeApproved
run-name: "PR ${{github.event.number}} PRMergeApproved"
on:
pull_request_target:
types: [labeled]

concurrency:
group: ${{github.workflow}}-${{github.event.label.name}}-${{github.event.number}}
cancel-in-progress: true

jobs:
MergePR:
name: MergePR
if: contains(fromJSON(vars.MERGE_APPROVED_LABELS), github.event.label.name)
uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskMergePR.yml@main
with:
dry_run: true
secrets:
TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 6facfd1

Please sign in to comment.