1
1
mirror of https://github.com/primer/css.git synced 2024-12-28 16:45:52 +03:00
css/.github/workflows/welcome.yml

132 lines
4.6 KiB
YAML
Raw Normal View History

name: Welcome
on:
pull_request:
jobs:
release-template:
2021-09-03 19:10:33 +03:00
if: ${{ github.head_ref == 'changeset-release/main' || github.head_ref == 'changeset-release/next_major' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Get or Create Comment
uses: actions/github-script@v6
with:
2021-05-05 23:34:10 +03:00
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs')
2021-05-05 23:26:41 +03:00
const body = await fs.readFileSync('.github/release_template.md', 'utf8')
const result = await github.rest.issues.listComments({
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]')
if (!primerComments.length) {
await github.rest.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: release-template
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
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]
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
- 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]
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 "\`\`\`"
fi
label-release:
2021-10-21 20:14:59 +03:00
if: ${{ github.repository == 'primer/css' }}
name: Semantic Version Label
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
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)]
if (match && match[0]) {
return match[0][1]
}
- uses: actions/github-script@v6
env:
RELEASE: ${{ steps.version-result.outputs.result }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
if (process.env.RELEASE == 'undefined') { return }
const issue = await github.rest.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) {
2021-12-14 23:50:21 +03:00
github.rest.issues.removeLabel({
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({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [newLabel]
})
}