Skip to content

Test Formatting

Test Formatting #1303

Workflow file for this run

name: CI
on: [push, pull_request]
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
env:
CACHE_BRANCH: credits-cache
BLOCKLIST: |
[]
jobs:
linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: lilia
- uses: leafo/gh-actions-lua@v8.0.0
with:
luaVersion: "5.2"
- uses: leafo/gh-actions-luarocks@v4.0.0
- name: Pull gluacheck
uses: actions/checkout@v3
with:
repository: LiliaFramework/GluaCheck
path: luacheck
- name: Build gluacheck
working-directory: luacheck
run: luarocks make
- name: Lint
working-directory: lilia
run: |
luacheck . --no-redefined \
--no-global --no-self \
--no-max-line-length --no-max-code-line-length \
--no-max-string-line-length --no-max-comment-line-length \
--no-max-cyclomatic-complexity
docs:
runs-on: ubuntu-latest
needs: linter
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'LiliaFramework/Lilia' && success()
steps:
- uses: actions/checkout@v3
with:
path: lilia
- uses: leafo/gh-actions-lua@v8.0.0
with:
luaVersion: "5.2"
- uses: leafo/gh-actions-luarocks@v4.0.0
- name: Pull LDoc
uses: actions/checkout@v3
with:
repository: LiliaFramework/LDoc
path: ldoc
- name: Build LDoc
working-directory: ldoc
run: luarocks make
- name: Build docs
working-directory: lilia
run: ldoc . --fatalwarnings
- name: Copy assets
working-directory: lilia
run: |
cp -v docs/css/* docs/html
cp -v docs/js/* docs/html
- name: Deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'LiliaFramework/Lilia' && success()
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: lilia/docs/html
sync:
runs-on: ubuntu-latest
needs: docs
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'LiliaFramework/Lilia' && success()
steps:
- name: Checkout source repository
uses: actions/checkout@v3
- name: Push to destination repository
env:
GITHUB_TOKEN: ${{ secrets.LiliaGitSecret }}
ORIGINAL_REPO_NAME: ${{ github.event.repository.name }}
ORG_NAME: LiliaFramework
run: |
git config --global user.email "githubactions@github.com"
git config --global user.name "Github Actions"
git clone https://${ORG_NAME}:${GITHUB_TOKEN}@github.com/${ORG_NAME}/LiliaFramework.github.io.git liliagit
cd liliagit
git remote add ${ORIGINAL_REPO_NAME} https://${ORG_NAME}:${GITHUB_TOKEN}@github.com/${ORG_NAME}/${{ env.ORIGINAL_REPO_NAME }}.git
git remote update
git merge ${ORIGINAL_REPO_NAME}/gh-pages --allow-unrelated-histories gh-pages
git push origin gh-pages
build-cache:
runs-on: ubuntu-latest
needs: [linter, docs, sync]
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4.1.5
with:
ref: ${{ env.CACHE_BRANCH }}
fetch-depth: 0
- uses: actions/github-script@v7.0.1
id: getContributors
with:
script: |
const { data: contributors } = await github.rest.repos.listContributors({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 50,
})
return contributors
- uses: actions/github-script@v7.0.1
id: getNames
env:
getContributors: ${{ steps.getContributors.outputs.result }}
with:
github-token: ${{ secrets.LiliaGitSecret }}
script: |
const contributors = JSON.parse(process.env.getContributors)
var query = "query{search(first:50query:\""
for (i = 0; i < contributors.length; i++) {
const contributor = contributors[i]
if (contributor.login) {
query += "user:" + contributor.login + " "
}
}
query += "\"type:USER){nodes{... on User {name id}}}}"
const { search: result } = await github.graphql(query)
return result.nodes
- uses: actions/github-script@v7.0.1
id: buildData
env:
getContributors: ${{ steps.getContributors.outputs.result }}
getNames: ${{ steps.getNames.outputs.result }}
with:
script: |
const fs = require("fs")
const util = require("util")
const writeFileAsync = util.promisify(fs.writeFile)
const blocklist = JSON.parse(process.env.BLOCKLIST)
const contributors = JSON.parse(process.env.getContributors)
const names = JSON.parse(process.env.getNames)
var blockedUsers = {}
for (i = 0; i < blocklist.length; i++) {
blockedUsers[blocklist[i]] = true
}
var namedUsers = {}
for (i = 0; i < names.length; i++) {
namedUsers[names[i].id] = names[i].name
}
var contributorMetadata = []
for (i = 0; i < contributors.length; i++) {
const contributor = contributors[i]
if (!blockedUsers[contributor.id]) {
contributorMetadata.push({
id: contributor.id,
name: namedUsers[contributor.node_id] ? namedUsers[contributor.node_id] : contributor.login,
login: contributor.login,
})
const avatarData = await fetch("https://avatars.githubusercontent.com/u/" + contributor.id, {
method: "GET",
headers: {
'Accept': 'image/avif,image/webp,*/*'
},
})
const blob = await avatarData.blob()
const arrayBuffer = await blob.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
await writeFileAsync("./" + contributor.id, buffer)
}
}
await writeFileAsync("./contributors.json", JSON.stringify(contributorMetadata))
- name: Commit files
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit --allow-empty -a -m "Rebuild credits-cache"
- name: Push changes
uses: ad-m/github-push-action@v0.8.0
with:
github_token: ${{ secrets.LiliaGitSecret }}
branch: ${{ env.CACHE_BRANCH }}
force: true