Skip to content

Commit

Permalink
migrate to hugo
Browse files Browse the repository at this point in the history
Signed-off-by: David Karlsson <[email protected]>
  • Loading branch information
David Karlsson authored and dvdksn committed Aug 22, 2023
1 parent 4bbeb20 commit a0d21ad
Show file tree
Hide file tree
Showing 2,288 changed files with 251,077 additions and 37,903 deletions.
3 changes: 0 additions & 3 deletions .docker/Dockerfile.devenv

This file was deleted.

3 changes: 0 additions & 3 deletions .docker/config.json

This file was deleted.

13 changes: 6 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
.github
.gitignore
.idea
.jekyll-cache
.jekyll-metadata
.sass-cache
tests
_releaser
_site
CONTRIBUTING.md
Dockerfile
docker-compose.yml
/vendor
compose.yml
docker-bake.hcl
public
node_modules
resources
tmp
5 changes: 0 additions & 5 deletions .editorconfig

This file was deleted.

2 changes: 0 additions & 2 deletions .env

This file was deleted.

58 changes: 10 additions & 48 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,22 @@ jobs:
name: Build
uses: docker/bake-action@v2
with:
files: |
docker-bake.hcl
targets: release
set: |
*.cache-from=type=gha,scope=build
*.cache-to=type=gha,scope=build,mode=max
*.args.HUGO_ENV=production
validate:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
target:
- htmltest
- mdl
- lint
- test
steps:
-
name: Checkout
Expand All @@ -48,56 +51,13 @@ jobs:
name: Validate
uses: docker/bake-action@v2
with:
targets: ${{ matrix.target }}-output
files: |
docker-bake.hcl
targets: ${{ matrix.target }}
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 "htmltest":
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: 'HTML test 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.
Expand All @@ -114,6 +74,8 @@ jobs:
name: Build
uses: docker/bake-action@v2
with:
files: |
docker-bake.hcl
targets: releaser-build
set: |
*.cache-from=type=gha,scope=releaser
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ jobs:
-
name: Prepare
run: |
JEKYLL_ENV=development
HUGO_ENV=development
DOCS_AWS_REGION=us-east-1
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
HUGO_ENV=staging
DOCS_URL="https://docs-stage.docker.com"
DOCS_AWS_IAM_ROLE="arn:aws:iam::710015040892:role/stage-docs-docs.docker.com-20220818202135984800000001"
DOCS_S3_BUCKET="stage-docs-docs.docker.com"
Expand All @@ -32,7 +33,7 @@ jobs:
DOCS_LAMBDA_FUNCTION_REDIRECTS="DockerDocsRedirectFunction-stage"
DOCS_SLACK_MSG="Successfully deployed docs-stage from main branch. $DOCS_URL"
elif [ "${{ github.ref }}" = "refs/heads/published" ]; then
JEKYLL_ENV=production
HUGO_ENV=production
DOCS_URL="https://docs.docker.com"
DOCS_AWS_IAM_ROLE="arn:aws:iam::710015040892:role/prod-docs-docs.docker.com-20220818202218674300000001"
DOCS_S3_BUCKET="prod-docs-docs.docker.com"
Expand All @@ -41,6 +42,7 @@ jobs:
DOCS_LAMBDA_FUNCTION_REDIRECTS="DockerDocsRedirectFunction-prod"
DOCS_SLACK_MSG="Successfully deployed docs from published branch. $DOCS_URL"
elif [ "${{ github.ref }}" = "refs/heads/lab" ]; then
HUGO_ENV=lab
DOCS_URL="https://docs-labs.docker.com"
DOCS_AWS_IAM_ROLE="arn:aws:iam::710015040892:role/labs-docs-docs.docker.com-20220818202218402500000001"
DOCS_S3_BUCKET="labs-docs-docs.docker.com"
Expand All @@ -56,7 +58,7 @@ jobs:
SEND_SLACK_MSG="false"
fi
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "JEKYLL_ENV=$JEKYLL_ENV" >> $GITHUB_ENV
echo "HUGO_ENV=$HUGO_ENV" >> $GITHUB_ENV
echo "DOCS_URL=$DOCS_URL" >> $GITHUB_ENV
echo "DOCS_AWS_REGION=$DOCS_AWS_REGION" >> $GITHUB_ENV
echo "DOCS_AWS_IAM_ROLE=$DOCS_AWS_IAM_ROLE" >> $GITHUB_ENV
Expand All @@ -78,6 +80,8 @@ jobs:
name: Build website
uses: docker/bake-action@v2
with:
files: |
docker-bake.hcl
targets: release
set: |
*.cache-from=type=gha,scope=deploy-${{ env.BRANCH_NAME }}
Expand All @@ -93,12 +97,14 @@ jobs:
name: Upload files to S3 bucket
if: ${{ env.DOCS_S3_BUCKET != '' }}
run: |
aws --region ${{ env.DOCS_AWS_REGION }} s3 sync --acl public-read _site s3://${{ env.DOCS_S3_BUCKET }}/ --delete
aws --region ${{ env.DOCS_AWS_REGION }} s3 sync --acl public-read public s3://${{ env.DOCS_S3_BUCKET }}/ --delete
-
name: Update S3 config
if: ${{ env.DOCS_S3_BUCKET != '' && env.DOCS_S3_CONFIG != '' }}
uses: docker/bake-action@v2
with:
files: |
docker-bake.hcl
targets: aws-s3-update-config
set: |
*.cache-from=type=gha,scope=releaser
Expand All @@ -111,6 +117,8 @@ jobs:
if: ${{ env.DOCS_CLOUDFRONT_ID != '' }}
uses: docker/bake-action@v2
with:
files: |
docker-bake.hcl
targets: aws-cloudfront-update
env:
AWS_REGION: us-east-1 # cloudfront and lambda edge functions are only available in us-east-1 region
Expand Down
66 changes: 13 additions & 53 deletions .github/workflows/validate-upstream.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# reusable workflow to validate docs from upstream repository for which pages are remotely fetched
# - repo: repository to handle from fetch-remote in _config.yml (e.g., https://github.com/docker/buildx)
# - repo: upstream repository (e.g., https://github.com/docker/buildx)
# - data-files-id: id of the artifact (using actions/upload-artifact) containing the YAML data files to validate (optional)
# - data-files-folder: folder in _data containing the files to download and copy to (e.g., buildx)
name: validate-upstream

on:
workflow_call:
inputs:
repo:
required: true
type: string
data-files-id:
required: false
type: string
Expand All @@ -29,57 +26,16 @@ jobs:
uses: actions/checkout@v3
with:
repository: docker/docs
-
name: Install js-yaml
run: npm install js-yaml
-
name: Set correct ref to fetch remote resources
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const yaml = require('js-yaml');
const configFile = '_config.yml'
const config = yaml.load(fs.readFileSync(configFile, 'utf8'));
for (const remote of config['fetch-remote']) {
if (remote['repo'] != '${{ inputs.repo }}') {
continue;
}
if ("${{ github.event_name }}" == "pull_request") {
remote['repo'] = "${{ github.event.pull_request.head.repo.html_url }}";
remote['ref'] = "${{ github.event.pull_request.head.ref }}"
} else {
remote['ref'] = "${{ github.ref_name }}";
}
}
try {
fs.writeFileSync(configFile, yaml.dump(config), 'utf8')
} catch (err) {
console.error(err.message)
process.exit(1)
}
-
name: Prepare
run: |
# print docs jekyll config updated in previous step
yq _config.yml
# cleanup js-yaml module and data files
rm -rf ./node_modules
if [[ -n "${{ inputs.data-files-folder }}" ]] && [[ -d "./_data/${{ inputs.data-files-folder }}" ]]; then
rm -rf ./_data/${{ inputs.data-files-folder }}/*
fi
-
name: Download data files
uses: actions/download-artifact@v3
if: ${{ inputs.data-files-id != '' && inputs.data-files-folder != '' }}
with:
name: ${{ inputs.data-files-id }}
path: /tmp/_data/${{ inputs.data-files-folder }}
path: /tmp/data/${{ inputs.data-files-folder }}
-
# Copy data files from /tmp/_data/${{ inputs.data-files-folder }} to
# _data/${{ inputs.data-files-folder }}. If data-files-placeholder-folder
# Copy data files from /tmp/data/${{ inputs.data-files-folder }} to
# data/${{ inputs.data-files-folder }}. If data-files-placeholder-folder
# is set, then check if a placeholder file exists for each data file in
# that folder. If not, then creates a placeholder file with the same
# name as the data file, but with a .md extension.
Expand All @@ -90,19 +46,19 @@ jobs:
script: |
const fs = require('fs');
const path = require('path');
const dataFilesPlaceholderFolder = `${{ inputs.data-files-placeholder-folder }}`;
const globber = await glob.create(`/tmp/_data/${{ inputs.data-files-folder }}/*.yaml`);
const dataFilesPlaceholderFolder = `content/${{ inputs.data-files-placeholder-folder }}`;
const globber = await glob.create(`/tmp/data/${{ inputs.data-files-folder }}/*.yaml`);
for await (const yamlSrcPath of globber.globGenerator()) {
const yamlSrcFilename = path.basename(yamlSrcPath);
const yamlDestPath = path.join('_data', `${{ inputs.data-files-folder }}`, yamlSrcFilename);
const yamlDestPath = path.join('data', `${{ inputs.data-files-folder }}`, yamlSrcFilename);
const placeholderPath = path.join(dataFilesPlaceholderFolder, yamlSrcFilename.replace(/^docker_/, '').replace(/\.yaml$/, '.md'));
if (dataFilesPlaceholderFolder !== '' && !fs.existsSync(placeholderPath)) {
const placeholderContent = `---
datafolder: ${{ inputs.data-files-folder }}
datafile: ${yamlSrcFilename.replace(/\.[^/.]+$/, '')}
title: ${yamlSrcFilename.replace(/\.[^/.]+$/, "").replaceAll('_', ' ')}
---
{% include cli.md datafolder=page.datafolder datafile=page.datafile %}`;
layout: cli
---`;
await core.group(`creating ${placeholderPath}`, async () => {
core.info(placeholderContent);
});
Expand All @@ -118,7 +74,11 @@ jobs:
name: Validate
uses: docker/bake-action@v2
with:
files: |
docker-bake.hcl
targets: validate
set: |
*.args.REPO="github.com/${{ github.repository }}"
*.args.HUGO_MODULE_REPLACEMENTS="github.com/${{ github.repository }} -> github.com/${{ github.repository}} ${{ github.ref }}"
*.cache-from=type=gha,scope=docs-upstream
*.cache-to=type=gha,scope=docs-upstream,mode=max
16 changes: 6 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
**/.DS_Store
**/desktop.ini
.bundle/**
.jekyll-cache
.jekyll-metadata
_site/**
.sass-cache/**
.vscode
CNAME
_kbase/**
/vendor
/lint
tmp/.htmltest/**
node_modules
hugo_stats.json
.hugo_build.lock
resources
public
tmp
2 changes: 1 addition & 1 deletion .htmltest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DirectoryPath: "_site"
DirectoryPath: "public"
EnforceHTTPS: false
CheckDoctype: false
CheckExternal: false
Expand Down
21 changes: 0 additions & 21 deletions .markdownlint.rb

This file was deleted.

Empty file removed .nojekyll
Empty file.
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["prettier-plugin-tailwindcss"]
}
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

Loading

0 comments on commit a0d21ad

Please sign in to comment.