2021-04-10 23:20:13 +03:00
|
|
|
name: Welcome
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
|
|
|
|
jobs:
|
2021-05-05 23:30:49 +03:00
|
|
|
release-template:
|
2021-09-03 19:10:33 +03:00
|
|
|
if: ${{ github.head_ref == 'changeset-release/main' || github.head_ref == 'changeset-release/next_major' }}
|
2021-04-10 23:20:13 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2022-04-12 23:38:08 +03:00
|
|
|
uses: actions/checkout@v3
|
2021-04-10 23:20:13 +03:00
|
|
|
|
|
|
|
- name: Set up Node.js
|
2022-04-01 11:04:41 +03:00
|
|
|
uses: actions/setup-node@v3
|
2021-04-10 23:20:13 +03:00
|
|
|
with:
|
|
|
|
node-version: 14.x
|
|
|
|
|
|
|
|
- name: Get or Create Comment
|
2022-04-20 19:24:28 +03:00
|
|
|
uses: actions/github-script@v6
|
2021-04-10 23:20:13 +03:00
|
|
|
with:
|
2021-05-05 23:34:10 +03:00
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
2021-04-10 23:20:13 +03:00
|
|
|
script: |
|
|
|
|
const fs = require('fs')
|
2021-05-05 23:26:41 +03:00
|
|
|
const body = await fs.readFileSync('.github/release_template.md', 'utf8')
|
2021-09-27 21:17:39 +03:00
|
|
|
const result = await github.rest.issues.listComments({
|
2021-04-10 23:20:13 +03:00
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo
|
|
|
|
});
|
2021-05-06 00:21:10 +03:00
|
|
|
console.log(result.data)
|
2021-05-06 00:22:50 +03:00
|
|
|
const primerComments = result.data.filter(c => c.user.login == 'github-actions[bot]')
|
2021-04-10 23:20:13 +03:00
|
|
|
if (!primerComments.length) {
|
2021-09-27 21:17:39 +03:00
|
|
|
await github.rest.issues.createComment({
|
2021-04-10 23:20:13 +03:00
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
body: body.replace('{{PR_AUTHOR}}', context.payload.sender.login)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
bundle-stats:
|
2021-05-05 23:30:49 +03:00
|
|
|
needs: release-template
|
2021-04-10 23:20:13 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-04-12 23:38:08 +03:00
|
|
|
- uses: actions/checkout@v3
|
2022-04-01 11:04:41 +03:00
|
|
|
- uses: actions/setup-node@v3
|
2021-04-10 23:20:13 +03:00
|
|
|
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 }}
|
2021-05-06 00:22:50 +03:00
|
|
|
GITHUB_USER: github-actions[bot]
|
2021-04-10 23:20:13 +03:00
|
|
|
with:
|
|
|
|
comment-token: 'bundle_table'
|
|
|
|
script: |
|
2021-05-05 22:39:41 +03:00
|
|
|
bundles=$(script/bundle-size-report.js)
|
|
|
|
if [[ $bundles ]]; then
|
2021-05-05 23:01:33 +03:00
|
|
|
echo "### Bundles with a size change since [latest release](https://github.com/primer/css/releases/latest)"
|
|
|
|
echo ""
|
|
|
|
echo "$bundles"
|
2021-05-05 22:39:41 +03:00
|
|
|
fi
|
2021-04-10 23:20:13 +03:00
|
|
|
|
|
|
|
- name: Reporting selector diffs
|
|
|
|
uses: primer/comment-token-update@main
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2021-05-06 00:22:50 +03:00
|
|
|
GITHUB_USER: github-actions[bot]
|
2021-04-10 23:20:13 +03:00
|
|
|
with:
|
|
|
|
comment-token: 'diff_report'
|
|
|
|
script: |
|
|
|
|
diff=$(script/selector-diff-report)
|
|
|
|
if [[ $diff ]]; then
|
2021-05-05 23:01:33 +03:00
|
|
|
echo "### Selectors added/removed since [latest release](https://github.com/primer/css/releases/latest)"
|
|
|
|
echo ""
|
2021-04-10 23:41:46 +03:00
|
|
|
echo "\`\`\`diff"
|
2021-05-05 23:01:33 +03:00
|
|
|
echo "$diff"
|
2021-04-10 23:41:46 +03:00
|
|
|
echo "\`\`\`"
|
2021-04-10 23:20:13 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
label-release:
|
2021-10-21 20:14:59 +03:00
|
|
|
if: ${{ github.repository == 'primer/css' }}
|
2021-04-10 23:20:13 +03:00
|
|
|
name: Semantic Version Label
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-04-20 19:24:28 +03:00
|
|
|
- uses: actions/github-script@v6
|
2021-04-10 23:20:13 +03:00
|
|
|
id: version-result
|
|
|
|
with:
|
|
|
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
|
|
result-encoding: string
|
|
|
|
script: |
|
|
|
|
const diff_url = context.payload.pull_request.diff_url
|
2021-09-27 21:20:40 +03:00
|
|
|
const result = await github.request(diff_url)
|
2022-04-20 21:46:38 +03:00
|
|
|
const match = [...result.data.matchAll(/^\+['"]@primer\/css['"]:\s(patch|minor|major)/mg)]
|
2021-04-10 23:20:13 +03:00
|
|
|
if (match && match[0]) {
|
|
|
|
return match[0][1]
|
|
|
|
}
|
|
|
|
|
2022-04-20 19:24:28 +03:00
|
|
|
- uses: actions/github-script@v6
|
2021-04-10 23:20:13 +03:00
|
|
|
env:
|
|
|
|
RELEASE: ${{ steps.version-result.outputs.result }}
|
|
|
|
with:
|
|
|
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
|
|
|
script: |
|
|
|
|
if (process.env.RELEASE == 'undefined') { return }
|
2021-09-27 21:17:39 +03:00
|
|
|
const issue = await github.rest.issues.get({
|
2021-04-10 23:20:13 +03:00
|
|
|
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) {
|
2021-12-14 23:50:21 +03:00
|
|
|
github.rest.issues.removeLabel({
|
2021-04-10 23:20:13 +03:00
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
name: [otherReleaseLabels]
|
|
|
|
})
|
|
|
|
}
|
2021-09-30 00:34:38 +03:00
|
|
|
github.rest.issues.addLabels({
|
2021-04-10 23:20:13 +03:00
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
labels: [newLabel]
|
|
|
|
})
|
|
|
|
}
|