Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
chore: includes workflows for PR overview board
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Muñoz <[email protected]>
  • Loading branch information
juancho0202 committed Jul 26, 2023
1 parent 1e6e4e0 commit c0551b3
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 0 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/add-pr-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# SPDX-FileCopyrightText: 2023 Alliander N.V.
#
# SPDX-License-Identifier: Apache-2.0

name: Add pull requests to the overview board

on:
workflow_run:
workflows: [Prepare PR data]
types: [completed]

env:
todo: Pending
changes_requested: Changes Requested
approved: Approved

jobs:
read-data-and-automate:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
outputs:
pr_node_id: ${{ steps.pr_node_id.outputs.content }}
event_action: ${{ steps.event_action.outputs.content }}
review_pr_node_id: ${{ steps.review_pr_node_id.outputs.content }}
review_state: ${{ steps.review_state.outputs.content }}
steps:
# Data retrieval steps in case of a PR event
- name: Download PR data artifact
if: github.event.workflow_run.event == 'pull_request' || github.event.workflow_run.event == 'pull_request_target'
uses: dawidd6/action-download-artifact@v2
with:
workflow: Prepare PR data
run_id: ${{ github.event.workflow_run.id }}
name: PR_DATA
- name: Read PR event's PR_NODE_ID.txt
if: github.event.workflow_run.event == 'pull_request' || github.event.workflow_run.event == 'pull_request_target'
id: pr_node_id
uses: juliangruber/read-file-action@v1
with:
path: ./PR_NODE_ID.txt
trim: true
- name: Read PR event's EVENT_ACTION.txt
if: github.event.workflow_run.event == 'pull_request' || github.event.workflow_run.event == 'pull_request_target'
id: event_action
uses: juliangruber/read-file-action@v1
with:
path: ./EVENT_ACTION.txt
trim: true
# Data retrieval steps in case of a PR review event
- name: Download PR review data artifact
if: github.event.workflow_run.event == 'pull_request_review'
uses: dawidd6/action-download-artifact@v2
with:
workflow: Prepare PR data
run_id: ${{ github.event.workflow_run.id }}
name: REVIEW_DATA
- name: Read PR review event's PR_NODE_ID.txt
if: github.event.workflow_run.event == 'pull_request_review'
id: review_pr_node_id
uses: juliangruber/read-file-action@v1
with:
path: ./PR_NODE_ID.txt
trim: true
- name: Read PR review event's REVIEW_STATE.txt
if: github.event.workflow_run.event == 'pull_request_review'
id: review_state
uses: juliangruber/read-file-action@v1
with:
path: ./REVIEW_STATE.txt
trim: true
# Project automation steps
- name: Move PR to ${{ env.todo }}
if: ((github.event.workflow_run.event == 'pull_request' ||
github.event.workflow_run.event == 'pull_request_target') &&
(steps.event_action.outputs.content == 'opened' ||
steps.event_action.outputs.content == 'reopened')) ||
(github.event.workflow_run.event == 'pull_request_review' &&
steps.review_state.outputs.content == 'dismissed')
uses: leonsteinhaeuser/[email protected]
with:
project_id: 7
gh_token: ${{ secrets.ORG_GITHUB_ACTION_SECRET }}
organization: openscd
resource_node_id: ${{ github.event.workflow_run.event == 'pull_request_review' && steps.review_pr_node_id.outputs.content || steps.pr_node_id.outputs.content }}
status_value: ${{ env.todo }}
- name: Move PR to ${{env.approved}}
if: github.event.workflow_run.event == 'pull_request_review' && steps.review_state.outputs.content == 'approved'
uses: leonsteinhaeuser/[email protected]
with:
project_id: 7
gh_token: ${{ secrets.ORG_GITHUB_ACTION_SECRET }}
organization: openscd
resource_node_id: ${{ steps.review_pr_node_id.outputs.content }}
status_value: ${{ env.approved }}
- name: Move PR to ${{env.changes_requested}}
if: github.event.workflow_run.event == 'pull_request_review' && steps.review_state.outputs.content == 'changes_requested'
uses: leonsteinhaeuser/[email protected]
with:
project_id: 7
gh_token: ${{ secrets.ORG_GITHUB_ACTION_SECRET }}
organization: openscd
resource_node_id: ${{ steps.review_pr_node_id.outputs.content }}
status_value: ${{ env.changes_requested }}
37 changes: 37 additions & 0 deletions .github/workflows/save-pr-data-to-file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: 2023 Alliander N.V.
#
# SPDX-License-Identifier: Apache-2.0

name: Prepare PR data
# Necessary step to allow adding external PRs to the project board

on: [pull_request, pull_request_target, pull_request_review]

jobs:
save-pr-data:
name: Save PR data to file
runs-on: ubuntu-latest
if: ${{ (github.event.pull_request.base.repo.full_name != 'openscd/open-scd') && github.event.pull_request.user.login != 'github-actions[bot]' }}
steps:
- name: Save PR node_id and event_action to files
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
run: echo ${{ github.event.pull_request.node_id }} > PR_NODE_ID.txt && echo ${{ github.event.action }} > EVENT_ACTION.txt
- name: Archive PR node_id and event_action
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: actions/upload-artifact@v3
with:
name: PR_DATA
path: |
PR_NODE_ID.txt
EVENT_ACTION.txt
- name: Save PR node_id and review_state to files
if: github.event_name == 'pull_request_review'
run: echo ${{ github.event.pull_request.node_id }} > PR_NODE_ID.txt && echo ${{ github.event.review.state }} > REVIEW_STATE.txt
- name: Archive PR and review_state
if: github.event_name == 'pull_request_review'
uses: actions/upload-artifact@v3
with:
name: REVIEW_DATA
path: |
PR_NODE_ID.txt
REVIEW_STATE.txt

0 comments on commit c0551b3

Please sign in to comment.