Skip to content

Commit

Permalink
Merge pull request #3 from arewm/main
Browse files Browse the repository at this point in the history
Initial attempt at configuring the rendering framework.
  • Loading branch information
arewm authored Apr 25, 2024
2 parents cb7f9cb + 2e477af commit 21712c5
Show file tree
Hide file tree
Showing 70 changed files with 12,162 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
68 changes: 68 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright 2022 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License..
#
# SPDX-License-Identifier: Apache-2.0

---
name: Check pull request

'on':
pull_request:
branches:
- main

jobs:
antora:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/.npm
key: docs-${{ hashFiles('package-lock.json') }}
restore-keys: docs-

- uses: actions/setup-node@v3
with:
node-version-file: 'package.json'

- name: Setup Go environment
uses: actions/setup-go@v4
with:
go-version: '1.19'

- name: Install Dependencies
run: npm install

- name: Generate website
run: npm ci && npm run build

- name: Store pull request data
run: |
mkdir pull_request
echo ${{ github.event.pull_request.number }} > ./pull_request/number
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: website
path: |
public
pull_request
79 changes: 79 additions & 0 deletions .github/workflows/preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright 2022 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0s

name: Publish preview

on:
workflow_run:
workflows: ["Check pull request"]
types:
- completed

jobs:
preview:
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
steps:
- name: Download pull request artifact
uses: actions/github-script@v7
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const websiteArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == 'website'
})[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: websiteArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync('${{github.workspace}}/website.zip', Buffer.from(download.data));
- name: Unzip website artifact
run: unzip -q website.zip
- name: Setup pull request data
id: data
run: |
PR_NUMBER=$(head -1 pull_request/number)
PR_NUMBER=${PR_NUMBER//[^0-9]/}
echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_OUTPUT
echo "PR_URL=https://github.com/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}" >> $GITHUB_OUTPUT
- name: Preview on Netlify
uses: netlify/actions/cli@master
id: preview
with:
args: deploy --dir=public --alias="pr-${{ steps.data.outputs.PR_NUMBER }}" --message="Preview for ${{ steps.data.outputs.PR_URL}}"
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
- name: Add comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: Number(${{ steps.data.outputs.PR_NUMBER }}),
owner: context.repo.owner,
repo: context.repo.repo,
body: `🚀 Preview is available at ${{ steps.preview.outputs.NETLIFY_URL }}`
})
73 changes: 73 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright 2022 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

---
name: Publish website

'on':
push:
branches:
- main
repository_dispatch:
types:
- update

jobs:
antora:
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/.npm
key: docs-${{ hashFiles('package-lock.json') }}
restore-keys: docs-

- uses: actions/setup-node@v3
with:
node-version-file: 'package.json'

- name: Setup Go environment
uses: actions/setup-go@v4
with:
go-version: '1.19'

- name: Generate website
run: npm ci && npm run build

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: 'public'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
63 changes: 63 additions & 0 deletions .github/workflows/size-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Size label
on: pull_request_target
jobs:
size-label:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Install jq
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Size label
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate size
run: |
additions=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | jq '.additions')
deletions=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | jq '.deletions')
size=$((additions + deletions))
echo "SIZE=$size" >> $GITHUB_ENV
- name: Add label
run: |
if [ ${{ env.SIZE }} -gt 100 ]; then
echo "Adding size: XXL"
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
-d '["size: XXL"]'
elif [ ${{ env.SIZE }} -gt 50 ]; then
echo "Adding size: XL"
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
-d '["size: XL"]'
elif [ ${{ env.SIZE }} -gt 30 ]; then
echo "Adding size: L"
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
-d '["size: L"]'
elif [ ${{ env.SIZE }} -gt 15 ]; then
echo "Adding size: M"
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
-d '["size: M"]'
elif [ ${{ env.SIZE }} -gt 5 ]; then
echo "Adding size: S"
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
-d '["size: S"]'
else
echo "Adding size: XS"
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
-d '["size: XS"]'
fi
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# gitignore for HAC BS documentation git repository

# HAC BS documentation is stored in adoc (AsciiDoc) format. Typically the
# adoc is converting into HTML to verify syntax while writing the files,
# but the HTML file should not be stored in git since the HTML files will
# likely get out of sync with the source (adoc) files. Web browsers will read adoc and convert into HTML when displaying the contents.

**/*.html

# Python object files
*.py[cod]

# vim swap files
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# vim temporary files
*~

# tmp dir
tmp/

# Antora working directories
node_modules/
build/
public/
.idea/
.cache

# Netlify deploy output from preview workflow
deploy.json
.DS_Store
11 changes: 11 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"redhat.vscode-yaml",
"redhat.vscode-xml",
"timonwong.shellcheck",
"errata-ai.vale-server",
"asciidoctor.asciidoctor-vscode"
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"asciidoc.antora.enableAntoraSupport": true,
"editor.wordWrap": "on"
}
Loading

0 comments on commit 21712c5

Please sign in to comment.