Skip to content

Commit

Permalink
chore: update (#125)
Browse files Browse the repository at this point in the history
* chore: update

* fix: linting

* fix: linting

* fix: push board automation changes
  • Loading branch information
gordsport authored Feb 14, 2023
1 parent e790f09 commit 2689d3c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 154 deletions.
67 changes: 24 additions & 43 deletions .github/workflows/project_board_automation.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
---


name: 'Project Board Automation'
name: "Project Board Automation"

"on":
pull_request_target:
branches: [develop, main]
types: [synchronize, opened, reopened, labeled, unlabeled, ready_for_review, review_requested, converted_to_draft, closed]
types: [synchronize, opened, reopened, labeled, unlabeled, ready_for_review, review_requested, converted_to_draft, closed]
pull_request_review:
types: [submitted]
pull_request_review_comment:
types: [created]

# Configure the project specific variables
env:
Expand All @@ -34,17 +32,15 @@ concurrency:

jobs:
project-board-automation:
name: 'Linked Issues & Project Board Automation'
name: "Linked Issues & Project Board Automation"
runs-on: ubuntu-latest
permissions: write-all
outputs:
bot-pr-output: ${{ steps.bot-pr.outputs.is-bot }}
steps:
#######
## Gather data, reopen closed issues and ensure work item is on the board
#######
# yamllint disable rule:line-length
- name: 'Get linked issue id and state'
- name: "Get linked issue id and state"
id: linked-issue
env:
GH_TOKEN: ${{ secrets.GH_NEW_CARD_TO_PROJECT }}
Expand All @@ -64,15 +60,14 @@ jobs:
}' -f pr_url=$PR_URL > data.json
echo 'LINKED_ISSUE_STATE='$(jq '.data.resource.closingIssuesReferences.nodes[] | .state' data.json) >> $GITHUB_ENV
echo 'LINKED_ISSUE_ID='$(jq '.data.resource.closingIssuesReferences.nodes[] | .id' data.json) >> $GITHUB_ENV
- name: 'Check if PR raised by bot'
- name: "Check if PR raised by bot"
id: bot-pr
if: |
((startsWith(github.head_ref, 'renovate/') == true || startsWith(github.head_ref, 'dependabot/') == true)
|| (github.actor == 'dependabot[bot]' || github.actor == 'renovate[bot]'))
run: |
echo 'BOT_PR=true' >> $GITHUB_ENV
echo "is-bot=true" >> $GITHUB_OUTPUT
- name: 'Check for linked issue'
- name: "Check for linked issue"
id: linked
if: |
env.LINKED_ISSUE_ID != '' &&
Expand All @@ -82,7 +77,7 @@ jobs:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log("Linked Issue Found!");
- name: 'Check for linked issue exclusion label'
- name: "Check for linked issue exclusion label"
id: exclude-linked
if: |
steps.bot-pr.outcome == 'success' || env.LINKED_ISSUE_ID == '' &&
Expand All @@ -92,7 +87,7 @@ jobs:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log("Exclusion label added, or a bot-PR no linked issue required!");
- name: 'Fail if no linked issue or exclusion label'
- name: "Fail if no linked issue or exclusion label"
id: exclude-linked-error
if: steps.linked.outcome == 'skipped' && steps.exclude-linked.outcome == 'skipped'
uses: actions/github-script@v6.1.1
Expand All @@ -101,7 +96,7 @@ jobs:
script: |
console.log("No linked issue or exclusion label!");
core.setFailed("Link an issue and rerun, or, add the exclusion label!");
- name: 'Fail if linked issue AND exclusion label'
- name: "Fail if linked issue AND exclusion label"
id: linked-and-nochangelog
if: steps.linked.outcome == 'success' && steps.exclude-linked.outcome == 'success'
uses: actions/github-script@v6.1.1
Expand All @@ -110,7 +105,7 @@ jobs:
script: |
console.log("Remove exclusion label, linked issue found!");
core.setFailed("Remove exclusion label, linked issue found!");
- name: 'Get project related data'
- name: "Get project related data"
id: project-data
run: |
gh api graphql -f query='
Expand Down Expand Up @@ -157,8 +152,7 @@ jobs:
echo 'DONE_COLUMN='$(jq --arg done ${{ env.DONE_COLUMN_NAME }} '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name==$done) | .id' data.json) >> $GITHUB_ENV
echo 'ITERATION_FIELD_ID='$(jq --arg iteration_field_name $ITERATION_FIELD_NAME '.data.organization.projectV2.fields.nodes[] | select(.name==$iteration_field_name) | .id' data.json) >> $GITHUB_ENV
echo 'CURRENT_ITERATION='$(jq --arg iteration_field_name $ITERATION_FIELD_NAME '.data.organization.projectV2.fields.nodes[] | select(.name==$iteration_field_name) | .configuration.iterations[0] | .id' data.json) >> $GITHUB_ENV
- name: 'Get PR state, review decision and author'
- name: "Get PR state, review decision and author"
id: pr-status
run: |
gh api graphql -f query='
Expand Down Expand Up @@ -194,7 +188,7 @@ jobs:
echo 'PR_STATE='$(jq '.data.resource | .state' data.json) >> $GITHUB_ENV
echo 'PR_ID='$(jq '.data.resource | .id' data.json) >> $GITHUB_ENV
echo 'AUTHOR_NAME='$(jq '.data.resource.author | .login' data.json) >> $GITHUB_ENV
- name: 'Get PR author id'
- name: "Get PR author id"
id: pr-author
if: steps.pr-status.outcome == 'success'
run: |
Expand Down Expand Up @@ -234,7 +228,7 @@ jobs:
run: |
pr_item_id="$( gh api graphql -f query='
mutation($user:String!, $project:ID!, $pr:ID!) {
addProjectV2ItemById(input: {clientMutationId: $user, projectId: $project, contentId: $issue}) {
addProjectV2ItemById(input: {clientMutationId: $user, projectId: $project, contentId: $pr}) {
item {
id
}
Expand All @@ -247,14 +241,14 @@ jobs:
run: |
pr_item_id="$( gh api graphql -f query='
mutation($user:String!, $project:ID!, $pr:ID!) {
addProjectV2ItemById(input: {clientMutationId: $user, projectId: $project, contentId: $issue}) {
addProjectV2ItemById(input: {clientMutationId: $user, projectId: $project, contentId: $pr}) {
item {
id
}
}
}' -f project=$PROJECT_ID -f pr=$PR_ID -f user=$USER --jq '.data.addProjectV2ItemById.item.id')"
echo 'BOARD_ITEM_ID='$pr_item_id >> $GITHUB_ENV
- name: 'Reopen if the linked issue closed'
- name: "Reopen if the linked issue closed"
id: reopen-issue
if: steps.issue-to-project.outcome == 'success' && env.LINKED_ISSUE_STATE == '"CLOSED"' && env.PR_STATE != '"MERGED"'
run: |
Expand All @@ -272,22 +266,22 @@ jobs:
#######
## Set the variables ready to update work item on project board
#######
- name: 'Set draft work item for progress column'
- name: "Set draft work item for progress column"
id: draft-pr
if: github.event.pull_request.draft == 'true' || env.IS_PR_DRAFT == 'true'
run: |
echo 'ITEM_ID='${{ env.BOARD_ITEM_ID }} >> $GITHUB_ENV
echo 'CURRENT_ITERATION='$CURRENT_ITERATION >> $GITHUB_ENV
echo 'CURRENT_STATUS='${{ env.IN_PROGRESS_COLUMN }} >> $GITHUB_ENV
- name: 'Set work item for review required column'
- name: "Set work item for review required column"
id: review-required
if: |
github.event.action == 'ready_for_review' ||
env.IS_PR_DRAFT != 'true' && env.NUM_REVIEWS == 0 && env.REVIEW_DECISION == '"REVIEW_REQUIRED"'
run: |
echo 'ITEM_ID='${{ env.BOARD_ITEM_ID }} >> $GITHUB_ENV
echo 'CURRENT_STATUS='${{ env.REVIEW_REQUIRED_COLUMN }} >> $GITHUB_ENV
- name: 'Set work item for in review column'
- name: "Set work item for in review column"
id: changes-requested
if: |
(steps.draft-pr.outcome == 'skipped' && env.NUM_REVIEWS > 0 &&
Expand All @@ -296,21 +290,21 @@ jobs:
run: |
echo 'ITEM_ID='${{ env.BOARD_ITEM_ID }} >> $GITHUB_ENV
echo 'CURRENT_STATUS='${{ env.IN_REVIEW_COLUMN }} >> $GITHUB_ENV
- name: 'Set work item for approved column'
- name: "Set work item for approved column"
id: approved
if: |
(steps.draft-pr.outcome == 'skipped' && (env.REVIEW_DECISION == '"APPROVED"'
|| env.LATEST_REVIEW_STATE == '"APPROVED"'))
run: |
echo 'ITEM_ID='${{ env.BOARD_ITEM_ID }} >> $GITHUB_ENV
echo 'CURRENT_STATUS='${{ env.APPROVED_COLUMN }} >> $GITHUB_ENV
- name: 'Set work item for merged column'
- name: "Set work item for merged column"
id: merged
if: env.PR_STATE == '"MERGED"' || github.event.pull_request.merged == true
run: |
echo 'ITEM_ID='${{ env.BOARD_ITEM_ID }} >> $GITHUB_ENV
echo 'CURRENT_STATUS='${{ env.MERGED_COLUMN }} >> $GITHUB_ENV
- name: 'Close linked issue when PR mergd'
- name: "Close linked issue when PR merged"
id: close-issue
if: steps.merged.outcome == 'success' && steps.linked.outcome == 'success'
run: |
Expand All @@ -322,13 +316,13 @@ jobs:
}
}
}' -f clientMutationId=$AUTHOR_ID -f issueId=$LINKED_ISSUE_ID
- name: 'Set closed PR for done column'
- name: "Set closed PR for done column"
id: closed-pr
if: steps.exclude-linked.outcome == 'success' && github.event.pull_request.closed == true
run: |
echo 'ITEM_ID='${{ env.BOARD_ITEM_ID }} >> $GITHUB_ENV
echo 'CURRENT_STATUS='${{ env.DONE_COLUMN }} >> $GITHUB_ENV
- name: 'Set closed PR issue to in progress column'
- name: "Set closed PR issue to in progress column"
id: closed-pr-with-issue
if: steps.linked.outcome == 'success' && github.event.pull_request.merged == true && env.PR_STATE != '"MERGED"'
run: |
Expand Down Expand Up @@ -378,7 +372,6 @@ jobs:
-f status_value=${{ env.CURRENT_STATUS }} \
-f iteration_field=$ITERATION_FIELD_ID \
-f iteration_value=${{ env.CURRENT_ITERATION }}
verify-changelog-updated:
name: "Verify CHANGELOG Updated"
needs: project-board-automation
Expand All @@ -387,28 +380,16 @@ jobs:
github.event.pull_request.draft != true
&& contains(github.event.pull_request.labels.*.name, 'no-changelog') != true
steps:
- name: "Check if PR raised by bot"
id: bot-no-changelog
if: |
((startsWith(github.head_ref, 'renovate/') == true || startsWith(github.head_ref, 'dependabot/') == true)
|| (github.actor == 'dependabot[bot]' || github.actor == 'renovate[bot]'))
uses: actions/github-script@v6.3.3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log("A bot-PR so excluded from changelog!");
- name: "Checkout"
id: checkout
if: steps.bot-no-changelog.outcome == 'skipped'
uses: actions/checkout@v3
- name: "Check changelog entry"
id: check-changelog
if: steps.checkout.outcome == 'success'
uses: Zomzog/changelog-checker@v1.2.0
with:
fileName: CHANGELOG.md
noChangelogLabel: "no-changelog"
checkNotification: Simple
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# yamllint enable rule:line-length
# yamllint enable rule:line-length
37 changes: 0 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,3 @@ env:
In order for the action to know that the pull request does not require the mandate of a planned issue (as per the [no issue required](./docs/Process.md###pull-requests-with-no-issue-required) process) an exclusion label needs to be defined.

This label must be configured in the yaml file and also be present in each of the repositories that the work on the project board may come from.

## testing:

### test 1

> ℹ️ Info: This action has not been fully working with dependabot pull requests and is the subject of further testing. Happy path has been tested.
### test 2

```diff
! Note: This action has not been fully working with dependabot pull requests and is the subject of further testing. Happy path has been tested.

```

### test 3

$$\textcolor{orange}{\text{Note: This action has not been fully working with dependabot pull requests and is the subject of further testing. Happy path has been tested. }}$$

### test 4

> ⚠️ Information:
> ```diff
> ! This action has not been fully working with dependabot pull requests and is the subject of further testing. Happy path has been tested.
> ```
### test 5
```
⚠️ Information: This action has not been fully working with dependabot pull requests and is the subject of further testing. Happy path has been tested.
```
### test 6
<div class="boxed">
this is the text.
</div>
4 changes: 3 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

## Supported Versions

This is a test repo so use at your own peril
This is a test repository so use at your own peril

## Reporting a Vulnerability

Raise a ticket

testing the PR merge queue
73 changes: 0 additions & 73 deletions test.md

This file was deleted.

0 comments on commit 2689d3c

Please sign in to comment.