1
1
mirror of https://github.com/primer/css.git synced 2024-12-29 00:58:31 +03:00

Rename and use pull_request until it's in main

This commit is contained in:
Jon Rohan 2021-04-10 13:20:13 -07:00
parent 82ff1d9646
commit bcd5e40491
No known key found for this signature in database
GPG Key ID: B0BBE304A9A0AECB

126
.github/workflows/welcome.yml vendored Normal file
View File

@ -0,0 +1,126 @@
name: Welcome
on:
pull_request:
branches-ignore:
- 'changeset-release/main'
- 'dependabot/**'
jobs:
greetings:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Get or Create Comment
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GPR_AUTH_TOKEN_SHARED }}
script: |
const fs = require('fs')
const body = await fs.readFileSync('.github/greetings_template.md', 'utf8')
const result = await github.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
const primerComments = result.data.filter(c => c.user.login == 'primer-css')
if (!primerComments.length) {
await github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body.replace('{{PR_AUTHOR}}', context.payload.sender.login)
})
}
bundle-stats:
needs: greetings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- run: yarn
- run: yarn pretest
- name: Reporting bundle sizes
uses: primer/comment-token-update@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
comment-token: 'bundle_table'
script: |
echo "### Bundle size changes since latest release"
echo "```"
script/bundle-size-report.js
echo "```"
- name: Reporting selector diffs
uses: primer/comment-token-update@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
comment-token: 'diff_report'
script: |
diff=$(script/selector-diff-report)
if [[ $diff ]]; then
echo "### Selectors added/removed"
echo "```diff"
echo $diff
echo "```"
fi
label-release:
name: Semantic Version Label
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
id: version-result
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
result-encoding: string
script: |
const diff_url = context.payload.pull_request.diff_url
const result = await github.request(diff_url)
const match = [...result.data.matchAll(/^\+['"]@primer\/css['"]:\s(patch|minor|major)/m)]
if (match && match[0]) {
return match[0][1]
}
- uses: actions/github-script@v3
env:
RELEASE: ${{ steps.version-result.outputs.result }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
if (process.env.RELEASE == 'undefined') { return }
const issue = await github.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
})
const currentLabels = issue.data.labels.map( l => l.name)
const newLabel = `${process.env.RELEASE} release`
if (!currentLabels.includes(newLabel)) {
const otherReleaseLabels = currentLabels.filter( l => l.endsWith(' release'))
if (otherReleaseLabels.length) {
github.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: [otherReleaseLabels]
})
}
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [newLabel]
})
}