1
1
mirror of https://github.com/primer/css.git synced 2024-11-10 16:07:25 +03:00

Combine into one workflow

This commit is contained in:
Jon Rohan 2021-04-10 13:18:42 -07:00
parent 100cf09024
commit 9c658c0a48
No known key found for this signature in database
GPG Key ID: B0BBE304A9A0AECB
3 changed files with 91 additions and 97 deletions

View File

@ -1,38 +0,0 @@
name: Bundle stats
on: [pull_request]
jobs:
bundle:
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

View File

@ -1,5 +1,9 @@
name: Welcome
on: [pull_request]
on:
pull_request_target:
branches-ignore:
- 'changeset-release/main'
- 'dependabot/**'
jobs:
greetings:
@ -13,9 +17,6 @@ jobs:
with:
node-version: 14.x
# - name: Install dependencies
# run: yarn
- name: Get or Create Comment
uses: actions/github-script@v3
with:
@ -37,3 +38,89 @@ jobs:
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]
})
}

View File

@ -1,55 +0,0 @@
name: Triage
on:
pull_request_target:
branches-ignore:
- 'dependabot/**'
jobs:
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]
})
}