Skip to content

Commit

Permalink
Merge branch 'master' into feature/expose_spec_documents
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni authored Apr 12, 2022
2 parents 217a6c8 + 43cbe42 commit 4ac90b4
Show file tree
Hide file tree
Showing 9 changed files with 2,584 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,23 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Check if PR is draft or is up-to-date # such info is not available in the context of issue_comment event
- name: Add ready-to-merge label
uses: actions/github-script@v5
id: checkPR
with:
result-encoding: string
github-token: ${{ secrets.GH_TOKEN }}
script: |
let isDraft = false;
let isUpToDate = true;
const prDetailsUrl = context.payload.issue.pull_request.url;
const { data: pull } = await github.request(prDetailsUrl);
isDraft = pull.draft;
const { draft: isDraft} = pull;
if(!isDraft) {
console.log('adding ready-to-merge label...');
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['ready-to-merge']
})
}
const { data: comparison } =
await github.rest.repos.compareCommitsWithBasehead({
Expand All @@ -46,35 +52,19 @@ jobs:
});
if (comparison.behind_by !== 0) {
console.log(`This branch is behind the target by ${comparison.behind_by} commits`)
isUpToDate = false;
} else console.log(`This branch is up-to-date.`)
return { isDraft, isUpToDate };
- uses: actions-ecosystem/action-create-comment@v1
if: ${{ !fromJson(steps.checkPR.outputs.result).isUpToDate }}
with:
github_token: ${{ secrets.GH_TOKEN }}
body: |
Hello, @${{ github.actor }}! 👋🏼
This PR is not up to date with the base branch and can't be merged.
Please update your branch manually with the latest version of the base branch.
PRO-TIP: Add a comment to your PR with the text: `/au` or `/autoupdate` and our bot will take care of updating the branch in the future. The only requirement for this to work is to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in your PR.
Thanks 😄
- name: Add ready-to-merge label
if: ${{ !fromJson(steps.checkPR.outputs.result).isDraft }}
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['ready-to-merge']
})
console.log('adding out-of-date comment...');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Hello, @${{ github.actor }}! 👋🏼
This PR is not up to date with the base branch and can't be merged.
Please update your branch manually with the latest version of the base branch.
PRO-TIP: Add a comment to your PR with the text: \`/au\` or \`/autoupdate\` and our bot will take care of updating the branch in the future. The only requirement for this to work is to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in your PR.
Thanks 😄`
})
}
add-do-not-merge-label:
if: >
github.event.issue.pull_request &&
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/lighthouse-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Lighthouse CI

on:
pull_request_target:
branches:
- master
types: [opened, reopened, synchronize, ready_for_review]

jobs:
lighthouse-ci:
name: Lighthouse CI
runs-on: ubuntu-latest
if: "github.repository == 'asyncapi/website' && github.event.pull_request.draft == false &&!((github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'ci: update global workflows')) || (github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'chore(release):')) || (github.actor == 'allcontributors' && startsWith(github.event.pull_request.title, 'docs: add')))"

steps:
- uses: actions/checkout@v3

- name: Await Netlify Preview
uses: jakepartusch/wait-for-netlify-action@v1
id: netlify
with:
site_name: asyncapi-website
max_timeout: 300

- name: Lighthouse Audit
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@9.3.0
with:
urls: |
https://deploy-preview-$PR_NUMBER--asyncapi-website.netlify.app/
configPath: ./.github/workflows/lighthouserc.json
uploadArtifacts: true
temporaryPublicStorage: true
env:
PR_NUMBER: ${{ github.event.pull_request.number}}

- name: Lighthouse Score Report
id: lighthouse_score_report
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const result = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary
const links = ${{ steps.lighthouse_audit.outputs.links }}
const formatResult = (res) => Math.round((res * 100))
Object.keys(result).forEach(key => result[key] = formatResult(result[key]))
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'
const comment = [
`⚡️ [Lighthouse report](${Object.values(links)[0]}) for the changes in this PR:`,
'| Category | Score |',
'| --- | --- |',
`| ${score(result.performance)} Performance | ${result.performance} |`,
`| ${score(result.accessibility)} Accessibility | ${result.accessibility} |`,
`| ${score(result['best-practices'])} Best practices | ${result['best-practices']} |`,
`| ${score(result.seo)} SEO | ${result.seo} |`,
`| ${score(result.pwa)} PWA | ${result.pwa} |`,
' ',
`*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*`
].join('\n')
core.setOutput("comment", comment);
- name: LightHouse Statistic Comment
id: lighthouse_statistic_comment
uses: marocchino/sticky-pull-request-comment@v2.2.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: lighthouse
message: ${{ steps.lighthouse_score_report.outputs.comment }}
21 changes: 21 additions & 0 deletions .github/workflows/lighthouserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"ci": {
"assert": {
"assertions": {
"categories:accessibility": ["error", {"minScore": 0.70}]
}
},
"collect": {
"settings": {
"skipAudits": [
"robots-txt",
"canonical",
"tap-targets",
"is-crawlable",
"works-offline",
"offline-start-url"
]
}
}
}
}
6 changes: 5 additions & 1 deletion .github/workflows/link-check-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ jobs:
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'

# A configuration file can be included, indicating the properties of the link check action
# More information can be found here: https://github.com/tcort/markdown-link-check#config-file-format
# Create mlc_config.json file in the root of the directory

- name: Report workflow run status to Slack
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,action,eventName,ref,workflow
env:
SLACK_DOCS_CHANNEL: ${{ secrets.SLACK_DOCS_CHANNEL }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DOCS_CHANNEL }}
if: failure() # Only, on failure, send a message on the Slack Docs Channel (if there are broken links)
6 changes: 5 additions & 1 deletion .github/workflows/link-check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ jobs:
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
check-modified-files-only: 'yes' #Only modified files are checked on PRs
check-modified-files-only: 'yes' # Only modified files are checked on PRs

# A configuration file can be included, indicating the properties of the link check action
# More information can be found here: https://github.com/tcort/markdown-link-check#config-file-format
# Create mlc_config.json file in the root of the directory
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"lodash": "^4.17.21",
"markdown-to-txt": "^1.0.1",
"markdown-toc": "1.2.0",
"moment": "^2.26.0",
"moment": "^2.29.2",
"monaco-editor": "^0.20.0",
"next": "^11.1.3",
"node-fetch": "^2.6.7",
Expand Down
Loading

0 comments on commit 4ac90b4

Please sign in to comment.