Skip to content

test-reporting-node-release #28

test-reporting-node-release

test-reporting-node-release #28

name: Update Test Reporting (Node)
on:
workflow_dispatch: # manual trigger
repository_dispatch: # repository trigger
types:
- test-reporting-node-release
env:
FORCE_COLOR: 3
concurrency: update-test-reporting-node
permissions:
contents: read
pull-requests: write
jobs:
update:
name: Update Test Reporting (Node)
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: Brightspace/third-party-actions@actions/checkout
with:
token: ${{secrets.PR_MANAGE_TOKEN}}
- name: Set up node
uses: Brightspace/third-party-actions@actions/setup-node
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: |
npm ci
npm i -g npm-check-updates
- name: Get current version
id: current
run: |
VERSION=$(
npm ls --depth=0 -j d2l-test-reporting |
jq -r '.dependencies."d2l-test-reporting".version'
)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Update test reporting
run: |
npm up d2l-test-reporting
ncu d2l-test-reporting -u
npm i
- name: Get new version
id: new
run: |
VERSION=$(
npm ls --depth=0 -j d2l-test-reporting |
jq -r '.dependencies."d2l-test-reporting".version'
)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build
if: steps.current.outputs.version != steps.new.outputs.version
run: npm run build
- name: Handle changes
uses: Brightspace/third-party-actions@peter-evans/create-pull-request
id: changes
if: steps.current.outputs.version != steps.new.outputs.version
with:
token: ${{secrets.PR_MANAGE_TOKEN}}
commit-message: Update `d2l-test-reporting` to `${{steps.new.outputs.version}}`
branch: ghworkflow/update-test-reporting-node
title: Update `d2l-test-reporting` to `${{steps.new.outputs.version}}`
body: Update `d2l-test-reporting` to `${{steps.new.outputs.version}}`
delete-branch: true
add-paths: |
dist/*
package.json
package-lock.json
- name: Enable auto-merge
if: steps.changes.outputs.pull-request-operation == 'created'
run: gh pr merge --squash --auto "$PULL_REQUEST_URL"
env:
PULL_REQUEST_URL: ${{steps.changes.outputs.pull-request-url}}
GITHUB_TOKEN: ${{secrets.PR_MANAGE_TOKEN}}
- name: Approve
if: >
steps.changes.outputs.pull-request-operation == 'created' ||
steps.changes.outputs.pull-request-operation == 'updated'
run: gh pr review --approve "$PULL_REQUEST_URL"
env:
PULL_REQUEST_URL: ${{steps.changes.outputs.pull-request-url}}
GITHUB_TOKEN: ${{github.token}}
- name: Get pull request age
if: steps.changes.outputs.pull-request-operation == 'updated'
id: pr-age
run: |
CREATED_AT=$(gh pr view "$PR_NUMBER" --json createdAt -q '.createdAt')
CREATED=$(date -d "$CREATED_AT" '+%s')
NOW=$(date '+%s')
DAYS_STALE="$((($NOW - $CREATED) / (24 * 60 * 60)))"
echo "days=$DAYS_STALE" >> $GITHUB_OUTPUT
env:
PR_NUMBER: ${{steps.changes.outputs.pull-request-number}}
GITHUB_TOKEN: ${{github.token}}
- name: Notify automation stale
if: >
steps.changes.outputs.pull-request-operation == 'updated' &&
fromJSON(steps.pr-age.outputs.days) > 3
uses: Brightspace/third-party-actions@slackapi/slack-github-action
env:
SLACK_BOT_TOKEN: ${{secrets.D2L_SLACK_TOKEN}}
with:
channel-id: '#quality-enablement-alerts'
payload: >
{
"username": "Stale Test Reporting PR",
"icon_emoji": ":update-package-lock:",
"unfurl_media": false,
"unfurl_links": false,
"text": ":warning: ${{github.repository}} -> PR #${{steps.changes.outputs.pull-request-number}} (${{github.server_url}}/${{github.repository}}/pull/${{steps.changes.outputs.pull-request-number}}) to d2l-test-reporting has been open for more than 3 days.",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":warning: `${{github.repository}}` -> <${{github.server_url}}/${{github.repository}}/pull/${{steps.changes.outputs.pull-request-number}}|PR #${{steps.changes.outputs.pull-request-number}}> to update `d2l-test-reporting` has been open for more than 3 days."
}
}
]
}
- name: Notify automation failure
if: failure()
uses: Brightspace/third-party-actions@slackapi/slack-github-action
env:
SLACK_BOT_TOKEN: ${{secrets.D2L_SLACK_TOKEN}}
with:
channel-id: '#quality-enablement-alerts'
payload: >
{
"username": "Update Test Reporting Issue",
"icon_emoji": ":update-package-lock:",
"unfurl_media": false,
"unfurl_links": false,
"text": ":fire: ${{github.repository}} -> Update run failed.\nSee ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} for details (trigger: ${{github.event_name}}, run attempt: ${{github.run_attempt}})",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":fire: `${{github.repository}}` -> Update run failed.\nSee the <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|run logs> for details (trigger: `${{github.event_name}}`, run attempt: ${{github.run_attempt}})"
}
}
]
}