Bump peter-evans/repository-dispatch from 2 to 3 #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Pull Request Automation" | |
on: | |
pull_request_target: | |
#types: ["opened", "synchronize", "reopened", "edited", "labeled", "unlabeled"] | |
types: ["opened"] | |
jobs: | |
pr-automation: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/labeler@v4 | |
with: | |
repo-token: "${{ secrets.GITHUB_TOKEN }}" | |
- uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
// fetch a fresh set of labels, they might have changed earlier | |
const issueLabels = await github.rest.issues.listLabelsOnIssue({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number | |
}); | |
let labels = issueLabels.data.map(label => label.name); | |
let setLabels = false; | |
let target = context.payload.pull_request.base.ref; | |
if (["maintenance", "devel", "staging/maintenance", "staging/devel", "master"].includes(target)) { | |
labels.push(`targets ${target}`); | |
setLabels = true; | |
} | |
if (setLabels) { | |
github.rest.issues.setLabels({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: labels | |
}) | |
} | |
- uses: OctoPrint/actions/pr-validation@main | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} |