49 lines
1.6 KiB
YAML
49 lines
1.6 KiB
YAML
name: 'Package Pull Requests'
|
|
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- edited
|
|
- reopened
|
|
- synchronize
|
|
paths:
|
|
- 'packages/**'
|
|
|
|
jobs:
|
|
packages-affected:
|
|
name: List affected packages
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Get PR Commits
|
|
id: 'get-pr-commits'
|
|
uses: tim-actions/get-pr-commits@master
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Check subsystem
|
|
if: ${{ success() || failure() }}
|
|
uses: tim-actions/commit-message-checker-with-regex@v0.3.1
|
|
with:
|
|
commits: ${{ steps.get-pr-commits.outputs.commits }}
|
|
pattern: '^[\s]*(pkg\([^:\s\n]+\))[\s]*:'
|
|
error: 'Your commit message must start with pkg([package])'
|
|
|
|
- name: Get packages
|
|
id: 'get-packages'
|
|
shell: bash
|
|
run: |
|
|
COMMITS='${{ steps.get-pr-commits.outputs.commits }}'
|
|
PACKAGES=$(echo $COMMITS | jq .[].commit.message -r | grep -oP '^pkg\(\K[^:\h\n]+(?=\))' | sort -u | sed 's/^/* /')
|
|
PACKAGES=${PACKAGES//$'%'/'%25'}
|
|
PACKAGES=${PACKAGES//$'\n'/'%0A'}
|
|
PACKAGES=${PACKAGES//$'\r'/'%0D'}
|
|
echo "::set-output name=packages::$PACKAGES"
|
|
|
|
- name: 'Comment PR'
|
|
uses: actions/github-script@0.3.0
|
|
if: github.event_name == 'pull_request'
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
|
|
github.issues.createComment({ issue_number, owner, repo, body: "Affected packages:\n${{ steps.get-packages.outputs.packages }}" }); |