Skip to content

Commit

Permalink
ci: fix derivative warning and invalid pr labeler
Browse files Browse the repository at this point in the history
  • Loading branch information
rickstaa committed Mar 12, 2023
1 parent 46c1b4f commit 2508886
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/check_derivatives_change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
mkdir -p ./check_derivatives_change
echo ${{ steps.changed-files.outputs.any_changed }} > ./check_derivatives_change/derivative_files_changed
echo ${{ steps.changes.outputs.changed }} > ./check_derivatives_change/incorrect_derivative_change
echo ${{ github.event.number }} > ./check_derivatives_change/issue_number
- uses: actions/upload-artifact@v3
with:
name: check_derivatives_change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@ jobs:
addDerivativeChangeWarning:
runs-on: ubuntu-latest
name: Add warning if derivative change was detected
# if: github.event.workflow_run.event == 'pull_request'
if: github.event.workflow_run.event == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
name: check_derivatives_change
workflow: check_derivatives_change.yml
run_id: ${{github.event.workflow_run.id }}

- name: Retrieve derivative check result from artifacts
id: changed
run: |
derivative_files_changed=`cat derivative_files_changed`
echo "derivative_files_changed=${derivative_files_changed}" >> "${GITHUB_OUTPUT}"
issue_number=`cat issue_number`
echo "issue_number=${issue_number}" >> "${GITHUB_OUTPUT}"
- if: steps.changed.outputs.derivative_files_changed == 'true'
run: |
Expand All @@ -40,3 +46,4 @@ jobs:
message: |
${{ env.WARNING_MSG }}
comment_tag: execution
pr_number: ${{ steps.changed.outputs.issue_number }}
58 changes: 58 additions & 0 deletions .github/workflows/label_invalid_prs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Label invalid PRs

on:
workflow_run:
workflows: ["Check derivatives change"]
types:
- completed

permissions:
contents: read
pull-requests: write

jobs:
labelInvalidPRs:
runs-on: ubuntu-latest
name: Add warning if derivative change was detected
if: github.event.workflow_run.event == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
name: check_derivatives_change
workflow: check_derivatives_change.yml
run_id: ${{github.event.workflow_run.id }}

- name: Retrieve derivative check result from artifacts
id: changed
run: |
issue_number=`cat issue_number`
echo "issue_number=${issue_number}" >> "${GITHUB_OUTPUT}"
- name: Add 'invalid' label if PR changes were wrong.
if: github.event.workflow_run.conclusion == 'failure'
uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ['invalid']
})
- name: Remove 'invalid' label if PR changes were correct.
if: github.event.workflow_run.conclusion == 'success'
uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'invalid'
})

0 comments on commit 2508886

Please sign in to comment.