mirror of https://github.com/docker/docs.git
121 lines
3.4 KiB
YAML
121 lines
3.4 KiB
YAML
name: build
|
|
|
|
on:
|
|
push:
|
|
# needs push event on default branch otherwise cache is evicted when pull request is merged
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read # to fetch code (actions/checkout)
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
-
|
|
name: Build
|
|
uses: docker/bake-action@v2
|
|
with:
|
|
targets: release
|
|
set: |
|
|
*.cache-from=type=gha,scope=build
|
|
*.cache-to=type=gha,scope=build,mode=max
|
|
|
|
validate:
|
|
runs-on: ubuntu-20.04
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
target:
|
|
- htmlproofer
|
|
- mdl
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
-
|
|
name: Validate
|
|
uses: docker/bake-action@v2
|
|
with:
|
|
targets: ${{ matrix.target }}-output
|
|
set: |
|
|
*.cache-to=type=gha,scope=validate-${{ matrix.target }},mode=max
|
|
*.cache-from=type=gha,scope=validate-${{ matrix.target }}
|
|
*.cache-from=type=gha,scope=build
|
|
-
|
|
name: Annotate
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
const fs = require('fs');
|
|
const results = fs.readFileSync('lint/results', 'utf-8');
|
|
if (results.length == 0) {
|
|
process.exit(0);
|
|
}
|
|
|
|
// print results
|
|
console.log(results);
|
|
process.exitCode = 1;
|
|
|
|
// construct annotations by parsing output
|
|
switch ("${{ matrix.target }}") {
|
|
case "htmlproofer":
|
|
const re = /^- (.+)\n \* (.+) \(line (\d+)\)\n(.+)$/gm;
|
|
while (true) {
|
|
const result = re.exec(results);
|
|
if (result === null) {
|
|
break;
|
|
}
|
|
|
|
core.error(`${result[2]}\n${result[4]}`, {
|
|
title: 'Link check failed',
|
|
// file: result[1],
|
|
// startLine: result[3],
|
|
});
|
|
}
|
|
break;
|
|
case "mdl":
|
|
const jsonResults = JSON.parse(results);
|
|
for (const result of jsonResults) {
|
|
const title = result.rule + (result.aliases.length > 0 ? ` (${result.aliases[0]})` : ``);
|
|
console.log(`${result.filename}:${result.line}; ${title} - ${result.description}`);
|
|
core.error(result.description, {
|
|
title: title,
|
|
file: result.filename,
|
|
startLine: result.line,
|
|
});
|
|
}
|
|
break;
|
|
}
|
|
|
|
# build-releaser job will just build _releaser app used for Netlify and
|
|
# AWS deployment in publish workflow. it's just to be sure it builds correctly.
|
|
build-releaser:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
-
|
|
name: Build
|
|
uses: docker/bake-action@v2
|
|
with:
|
|
targets: releaser-build
|
|
set: |
|
|
*.cache-from=type=gha,scope=releaser
|
|
*.cache-to=type=gha,scope=releaser,mode=max
|