-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3079 from swryan/3048_poem_integrated
Added a workflow that will check transition a POEM to integrated when a PR is merged
- Loading branch information
Showing
4 changed files
with
147 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# When a pull request is opened, check if it resolves an issue that is associated with a POEM | ||
# When pull request is merged, update the status of any associated POEM to Integrated | ||
|
||
name: Check/Update Associated POEM | ||
|
||
on: | ||
pull_request_target: | ||
types: [ opened, closed ] | ||
branches: [ master ] | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
|
||
check_for_poem: | ||
if: github.event.action == 'opened' || github.event.pull_request.merged | ||
|
||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
repository-projects: write | ||
|
||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
steps: | ||
- name: Display run details | ||
run: | | ||
echo "=============================================================" | ||
echo "Run #${GITHUB_RUN_NUMBER}" | ||
echo "Run ID: ${GITHUB_RUN_ID}" | ||
echo | ||
echo "Repository: ${GITHUB_REPOSITORY}" | ||
echo "Triggered by: ${{ github.event_name }} ${{ github.event }}" | ||
echo "Initiated by: ${GITHUB_ACTOR}" | ||
echo "=============================================================" | ||
- name: Check for Associated POEM | ||
id: check_for_poem | ||
env: | ||
BODY: ${{ github.event.pull_request.body }} | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
echo "PULL REQUEST:" | ||
echo $BODY | ||
echo "----------------------" | ||
while IFS= read -r line; do | ||
ISSUE_ID=$(echo $line | grep "Resolves #" -) | ||
if [[ "$ISSUE_ID" ]]; then | ||
ISSUE_ID=$(echo $ISSUE_ID | cut -d '#' -f 2) | ||
break | ||
fi | ||
done <<< "$BODY" | ||
ISSUE_ID=$(echo $ISSUE_ID|tr -d '\n\t\r ') | ||
echo "ISSUE ID: $ISSUE_ID" | ||
echo "----------------------" | ||
ISSUE_TEXT=`gh --repo OpenMDAO/OpenMDAO issue view $ISSUE_ID` | ||
ASSOCIATED_POEM="" | ||
POEM_ID="" | ||
echo "ISSUE:" | ||
while IFS= read -r line; do | ||
echo $line | ||
if [[ "$ASSOCIATED_POEM" ]]; then | ||
POEM_ID=$(echo $line) | ||
if [[ "$POEM_ID" ]]; then | ||
break | ||
fi | ||
else | ||
ASSOCIATED_POEM=$(echo $line | grep "Associated POEM" -) | ||
fi | ||
done <<< "$ISSUE_TEXT" | ||
if [[ "$POEM_ID" ]]; then | ||
echo "----------------------" | ||
POEM_ID=$(echo $POEM_ID | tr -d '\n\t\r ') | ||
echo "This Pull Request will transition POEM $POEM_ID to Integrated" | ||
echo "----------------------" | ||
fi | ||
echo "POEM_ID=$POEM_ID" >> $GITHUB_OUTPUT | ||
- name: Comment on PR | ||
if: github.event.action == 'opened' && steps.check_for_poem.outputs.POEM_ID != '' | ||
env: | ||
POEM_ID: ${{ steps.check_for_poem.outputs.POEM_ID }} | ||
POEM_URL: ${{ github.server_url }}/${{ github.repository_owner }}/POEMs/blob/master/POEM_${{ steps.check_for_poem.outputs.POEM_ID }}.md | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: ${{ github.event.number }}, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'This pull request will transition [POEM_${{ env.POEM_ID }}](${{ env.POEM_URL }}) to `Integrated`' | ||
}) | ||
- name: Slack POEM message | ||
if: github.event.action == 'opened' && steps.check_for_poem.outputs.POEM_ID != '' | ||
uses: act10ns/slack@v2.0.0 | ||
with: | ||
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
status: 'warning' | ||
message: | | ||
Pull Request #${{ github.event.number }} will transition POEM_${{ steps.check_for_poem.outputs.POEM_ID }} to `Integrated` | ||
${{ github.server_url }}/${{ github.repository }}/pull/${{ github.event.number}} | ||
${{ github.server_url }}/${{ github.repository_owner }}/POEMs/blob/master/POEM_091.md | ||
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
- name: Update POEM status | ||
if: github.event.pull_request.merged == true && steps.check_for_poem.outputs.POEM_ID != '' | ||
uses: benc-uk/workflow-dispatch@v1 | ||
with: | ||
repo: ${{ github.repository_owner }}/POEMs | ||
workflow: Update POEM status to Integrated | ||
inputs: '{ "poem_integrated": "${{ steps.check_for_poem.outputs.POEM_ID }}" }' | ||
token: ${{ secrets.ACCESS_TOKEN }} |