-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into contribution_guide
- Loading branch information
Showing
4 changed files
with
159 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Update latest Extensions documentation in the website | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master" | ||
paths: | ||
- "extensions/*.md" | ||
|
||
|
||
jobs: | ||
Make-PR: | ||
name: Make PR on website repository with updated latest Extensions documentation | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
steps: | ||
- name: Checkout Current repository | ||
uses: actions/checkout@v3 | ||
with: | ||
path: extensions-catalog | ||
- name: Checkout Another repository | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: asyncapi/website | ||
path: website | ||
token: ${{ env.GITHUB_TOKEN }} | ||
- name: Config git | ||
run: | | ||
git config --global user.name asyncapi-bot | ||
git config --global user.email info@asyncapi.io | ||
- name: Create branch | ||
working-directory: ./website | ||
run: | | ||
git checkout -b update-extensions-docs-${{ github.sha }} | ||
- name: Update edit-page-config.json | ||
uses: actions/github-script@v4 | ||
with: | ||
script: | | ||
const { writeFile } = require('fs').promises; | ||
const configPath = './website/config/edit-page-config.json'; | ||
const checkSlug = 'reference/extensions/'; | ||
const slug = { | ||
"value": checkSlug, | ||
"href": "https://github.com/asyncapi/extensions-catalog/tree/master/extensions" | ||
}; | ||
const configData = require(configPath); | ||
const entryExists = configData.some(entry => entry.value === checkSlug); | ||
if (!entryExists) { | ||
configData.push(slug); | ||
await writeFile(configPath, JSON.stringify(configData, null, 2)) | ||
} | ||
- name: Update title and weight of the markdown files | ||
uses: actions/github-script@v4 | ||
with: | ||
script: | | ||
const fs = require('fs').promises; | ||
const path = require('path'); | ||
const folderPath = './extensions-catalog/extensions'; | ||
const files = await fs.readdir(folderPath); | ||
files.forEach(async (file, ind = 10) => { | ||
const filePath = path.join(folderPath, file); | ||
const baseName = path.basename(filePath, '.md'); | ||
const newData = `---\ntitle: '${baseName}' \nweight: ${ind + 11}\n---\n\n`; | ||
const existingFileData = await fs.readFile(filePath, 'utf8'); | ||
const updatedContent = newData + existingFileData; | ||
await fs.writeFile(filePath, updatedContent); | ||
}) | ||
- name: Copy extensions folder from Current Repo to Another | ||
working-directory: ./website | ||
run: | | ||
mkdir -p ./pages/docs/reference/extensions | ||
printf "%s\ntitle: Extensions\nweight: 10\n%s" "---" "---"> ../extensions-catalog/extensions/_section.md | ||
mv ../extensions-catalog/extensions/*.md ./pages/docs/reference/extensions | ||
- name: Commit and push | ||
working-directory: ./website | ||
run: | | ||
git add . | ||
git commit -m "docs(extension): update latest extensions docs" | ||
git push https://${{ env.GITHUB_TOKEN }}@github.com/asyncapi/website | ||
- name: Create PR | ||
working-directory: ./website | ||
run: | | ||
gh pr create --title "docs(extensions): update latest extensions documentation" --body "Updated extensions documentation is available and this PR introduces update to extensions folder on the website" --head "update-extensions-docs-${{ github.sha }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: YAML Lint Check | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
paths: | ||
- '.github/workflows/**' | ||
|
||
jobs: | ||
yaml-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Dependencies | ||
run: npm install yaml-lint ajv axios js-yaml | ||
|
||
- name: Lint YAML Files | ||
run: | | ||
set -e | ||
find .github/workflows -type f -name "*.yml" -print0 | xargs -0 ./node_modules/.bin/yamllint -q | ||
- name: List YAML files to validate | ||
run: | | ||
set -e | ||
files=$(find .github/workflows -name '*.yml') | ||
echo "Validating the following files:" | ||
echo "$files" | ||
- name: Run YAML validation | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const Ajv = require("ajv"); | ||
const axios = require("axios"); | ||
const yaml = require("js-yaml"); | ||
const fs = require("fs").promises; | ||
async function validateWorkflows() { | ||
const schema = await axios.get( | ||
"https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json" | ||
); | ||
const files = await fs.readdir(".github/workflows"); | ||
const ymlFiles = files.filter((file) => file.endsWith(".yml")); | ||
for (const file of ymlFiles) { | ||
try { | ||
const content = await fs.readFile(`.github/workflows/${file}`, "utf8"); | ||
const target = yaml.load(content); | ||
const ajv = new Ajv({ strict: false, allErrors: true }); | ||
const validator = ajv.compile(schema.data); | ||
const valid = validator(target); | ||
if (!valid) { | ||
console.error( | ||
`Validation failed for file '${file}' with the following errors:` | ||
); | ||
console.error(validator.errors); | ||
process.exitCode = 1; | ||
} else { | ||
console.log(`Workflow in file '${file}' is valid`); | ||
} | ||
} catch (error) { | ||
console.error(`Error validating file '${file}': ${error.message}`); | ||
process.exitCode = 1; | ||
} | ||
} | ||
} | ||
validateWorkflows(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters