mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Delete .github/workflows directory
remove workflows
This commit is contained in:
parent
755b91ab34
commit
ae146b1155
31
.github/workflows/crowdin.yml
vendored
31
.github/workflows/crowdin.yml
vendored
@ -1,31 +0,0 @@
|
|||||||
name: Crowdin Action
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
schedule:
|
|
||||||
- cron: '2 */12 * * *'
|
|
||||||
push:
|
|
||||||
paths: [
|
|
||||||
'/public/locales/en/**',
|
|
||||||
]
|
|
||||||
branches: [ dev ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
synchronize-with-crowdin:
|
|
||||||
name: Crowdin Sync
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: crowdin action
|
|
||||||
uses: crowdin/github-action@v2
|
|
||||||
with:
|
|
||||||
upload_translations: false
|
|
||||||
download_translations: true
|
|
||||||
crowdin_branch_name: dev
|
|
||||||
localization_branch_name: l10n_dev
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
|
||||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
|
164
.github/workflows/docker-publish.yml
vendored
164
.github/workflows/docker-publish.yml
vendored
@ -1,164 +0,0 @@
|
|||||||
name: Docker CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '20 0 * * *'
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- feature/**
|
|
||||||
- dev
|
|
||||||
tags: [ 'v*.*.*' ]
|
|
||||||
paths-ignore:
|
|
||||||
- 'docs/**'
|
|
||||||
- 'mkdocs.yml'
|
|
||||||
pull_request:
|
|
||||||
branches: [ "dev" ]
|
|
||||||
paths-ignore:
|
|
||||||
- 'docs/**'
|
|
||||||
- 'mkdocs.yml'
|
|
||||||
merge_group:
|
|
||||||
|
|
||||||
env:
|
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
pre-commit:
|
|
||||||
name: Linting Checks
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: 3.x
|
|
||||||
|
|
||||||
- name: Check files
|
|
||||||
uses: pre-commit/action@v3.0.1
|
|
||||||
|
|
||||||
- name: Install pnpm
|
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 10
|
|
||||||
run_install: false
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
cache: 'pnpm'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: pnpm install
|
|
||||||
|
|
||||||
- name: Lint frontend
|
|
||||||
run: pnpm run lint
|
|
||||||
|
|
||||||
build:
|
|
||||||
name: Docker Build & Push
|
|
||||||
if: github.repository == 'gethomepage/homepage'
|
|
||||||
runs-on: self-hosted
|
|
||||||
needs: [ pre-commit ]
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
id-token: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Extract Docker metadata
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
${{ env.IMAGE_NAME }}
|
|
||||||
ghcr.io/${{ env.IMAGE_NAME }}
|
|
||||||
tags: |
|
|
||||||
# Default tags
|
|
||||||
type=schedule,pattern=nightly
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=tag
|
|
||||||
# Versioning tags
|
|
||||||
type=semver,pattern=v{{version}}
|
|
||||||
type=semver,pattern=v{{major}}.{{minor}}
|
|
||||||
type=semver,pattern=v{{major}}
|
|
||||||
flavor: |
|
|
||||||
latest=auto
|
|
||||||
|
|
||||||
- name: Next.js build cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: .next/cache
|
|
||||||
key: nextjs-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx') }}
|
|
||||||
restore-keys: |
|
|
||||||
nextjs-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
|
||||||
|
|
||||||
- name: Install pnpm
|
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 10
|
|
||||||
run_install: false
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
cache: 'pnpm'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: pnpm install
|
|
||||||
|
|
||||||
- name: Build app
|
|
||||||
run: |
|
|
||||||
NEXT_PUBLIC_BUILDTIME="${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}" \
|
|
||||||
NEXT_PUBLIC_VERSION="${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}" \
|
|
||||||
NEXT_PUBLIC_REVISION="${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}" \
|
|
||||||
pnpm run build
|
|
||||||
|
|
||||||
- name: Log into registry ${{ env.REGISTRY }}
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Setup QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3.6.0
|
|
||||||
|
|
||||||
- name: Setup Docker buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
|
||||||
id: build-and-push
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
build-args: |
|
|
||||||
CI=true
|
|
||||||
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
|
|
||||||
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
|
|
||||||
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
|
||||||
|
|
||||||
# https://github.com/docker/build-push-action/issues/252 / https://github.com/moby/buildkit/issues/1896
|
|
||||||
- name: Move cache
|
|
||||||
run: |
|
|
||||||
rm -rf /tmp/.buildx-cache
|
|
||||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
|
84
.github/workflows/docs-publish.yml
vendored
84
.github/workflows/docs-publish.yml
vendored
@ -1,84 +0,0 @@
|
|||||||
name: Docs
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags: ["v*.*.*"]
|
|
||||||
branches: ["main"]
|
|
||||||
paths:
|
|
||||||
- "docs/**"
|
|
||||||
- "mkdocs.yml"
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- "docs/**"
|
|
||||||
- "mkdocs.yml"
|
|
||||||
merge_group:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
pre-commit:
|
|
||||||
name: Linting Checks
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Install python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: 3.x
|
|
||||||
- name: Check files
|
|
||||||
uses: pre-commit/action@v3.0.1
|
|
||||||
|
|
||||||
test:
|
|
||||||
name: Test Build
|
|
||||||
if: github.repository == 'gethomepage/homepage' && github.event_name == 'pull_request'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs:
|
|
||||||
- pre-commit
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: 3.x
|
|
||||||
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
|
||||||
- uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
key: mkdocs-material-${{ env.cache_id }}
|
|
||||||
path: .cache
|
|
||||||
restore-keys: |
|
|
||||||
mkdocs-material-
|
|
||||||
- run: sudo apt-get install pngquant
|
|
||||||
- run: pip install mkdocs-material mkdocs-redirects "mkdocs-material[imaging]"
|
|
||||||
- name: Test Docs Build
|
|
||||||
run: MKINSIDERS=false mkdocs build
|
|
||||||
deploy:
|
|
||||||
name: Build & Deploy
|
|
||||||
if: github.repository == 'gethomepage/homepage' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs:
|
|
||||||
- pre-commit
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Configure Git Credentials
|
|
||||||
run: |
|
|
||||||
git config user.name github-actions[bot]
|
|
||||||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
|
||||||
- uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: 3.x
|
|
||||||
- run: echo "cache_id=${{github.sha}}" >> $GITHUB_ENV
|
|
||||||
- uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
key: mkdocs-material-${{ env.cache_id }}
|
|
||||||
path: .cache
|
|
||||||
restore-keys: |
|
|
||||||
mkdocs-material-
|
|
||||||
- run: sudo apt-get install pngquant
|
|
||||||
- run: pip install git+https://${GH_TOKEN}@github.com/benphelps/mkdocs-material-insiders.git
|
|
||||||
- run: pip install mkdocs-redirects "mkdocs-material[imaging]"
|
|
||||||
- name: Docs Deploy
|
|
||||||
run: MKINSIDERS=true mkdocs gh-deploy --force
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
18
.github/workflows/reaction-comments.yml
vendored
18
.github/workflows/reaction-comments.yml
vendored
@ -1,18 +0,0 @@
|
|||||||
name: 'Reaction Comments'
|
|
||||||
|
|
||||||
on:
|
|
||||||
issue_comment:
|
|
||||||
types: [created, edited]
|
|
||||||
pull_request_review_comment:
|
|
||||||
types: [created, edited]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
actions: write
|
|
||||||
issues: write
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
action:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: dessant/reaction-comments@v4
|
|
280
.github/workflows/repo-maintenance.yml
vendored
280
.github/workflows/repo-maintenance.yml
vendored
@ -1,280 +0,0 @@
|
|||||||
name: 'Repository Maintenance'
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 3 * * *'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
issues: write
|
|
||||||
pull-requests: write
|
|
||||||
discussions: write
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: lock
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
stale:
|
|
||||||
name: 'Stale'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/stale@v9
|
|
||||||
with:
|
|
||||||
days-before-stale: 7
|
|
||||||
days-before-close: 14
|
|
||||||
stale-issue-label: stale
|
|
||||||
stale-pr-label: stale
|
|
||||||
stale-issue-message: >
|
|
||||||
This issue has been automatically marked as stale because it has not had
|
|
||||||
recent activity. It will be closed if no further activity occurs. Thank you
|
|
||||||
for your contributions. See our [contributing guidelines](https://github.com/gethomepage/homepage/blob/main/CONTRIBUTING.md#automatic-respoistory-maintenance) for more details.
|
|
||||||
lock-threads:
|
|
||||||
name: 'Lock Old Threads'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: dessant/lock-threads@v5
|
|
||||||
with:
|
|
||||||
issue-inactive-days: '30'
|
|
||||||
pr-inactive-days: '30'
|
|
||||||
discussion-inactive-days: '30'
|
|
||||||
log-output: true
|
|
||||||
issue-comment: >
|
|
||||||
This issue has been automatically locked since there
|
|
||||||
has not been any recent activity after it was closed.
|
|
||||||
Please open a new discussion for related concerns.
|
|
||||||
See our [contributing guidelines](https://github.com/gethomepage/homepage/blob/main/CONTRIBUTING.md#automatic-repository-maintenance) for more details.
|
|
||||||
pr-comment: >
|
|
||||||
This pull request has been automatically locked since there
|
|
||||||
has not been any recent activity after it was closed.
|
|
||||||
Please open a new discussion for related concerns.
|
|
||||||
See our [contributing guidelines](https://github.com/gethomepage/homepage/blob/main/CONTRIBUTING.md#automatic-repository-maintenance) for more details.
|
|
||||||
discussion-comment: >
|
|
||||||
This discussion has been automatically locked since there
|
|
||||||
has not been any recent activity after it was closed.
|
|
||||||
Please open a new discussion for related concerns.
|
|
||||||
See our [contributing guidelines](https://github.com/gethomepage/homepage/blob/main/CONTRIBUTING.md#automatic-repository-maintenance) for more details.
|
|
||||||
close-answered-discussions:
|
|
||||||
name: 'Close Answered Discussions'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
function sleep(ms) {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = `query($owner:String!, $name:String!) {
|
|
||||||
repository(owner:$owner, name:$name){
|
|
||||||
discussions(first:100, answered:true, states:[OPEN]) {
|
|
||||||
nodes {
|
|
||||||
id,
|
|
||||||
number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
const variables = {
|
|
||||||
owner: context.repo.owner,
|
|
||||||
name: context.repo.repo,
|
|
||||||
}
|
|
||||||
const result = await github.graphql(query, variables)
|
|
||||||
|
|
||||||
console.log(`Found ${result.repository.discussions.nodes.length} open answered discussions`)
|
|
||||||
|
|
||||||
for (const discussion of result.repository.discussions.nodes) {
|
|
||||||
console.log(`Closing discussion #${discussion.number} (${discussion.id})`)
|
|
||||||
|
|
||||||
const addCommentMutation = `mutation($discussion:ID!, $body:String!) {
|
|
||||||
addDiscussionComment(input:{discussionId:$discussion, body:$body}) {
|
|
||||||
clientMutationId
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
const commentVariables = {
|
|
||||||
discussion: discussion.id,
|
|
||||||
body: 'This discussion has been automatically closed because it was marked as answered. See our [contributing guidelines](https://github.com/gethomepage/homepage/blob/main/CONTRIBUTING.md#automatic-repository-maintenance) for more details.',
|
|
||||||
}
|
|
||||||
await github.graphql(addCommentMutation, commentVariables)
|
|
||||||
|
|
||||||
const closeDiscussionMutation = `mutation($discussion:ID!, $reason:DiscussionCloseReason!) {
|
|
||||||
closeDiscussion(input:{discussionId:$discussion, reason:$reason}) {
|
|
||||||
clientMutationId
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
const closeVariables = {
|
|
||||||
discussion: discussion.id,
|
|
||||||
reason: "RESOLVED",
|
|
||||||
}
|
|
||||||
await github.graphql(closeDiscussionMutation, closeVariables)
|
|
||||||
|
|
||||||
await sleep(1000)
|
|
||||||
}
|
|
||||||
close-outdated-discussions:
|
|
||||||
name: 'Close Outdated Discussions'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
function sleep(ms) {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
const CUTOFF_DAYS = 180;
|
|
||||||
const cutoff = new Date();
|
|
||||||
cutoff.setDate(cutoff.getDate() - CUTOFF_DAYS);
|
|
||||||
|
|
||||||
const query = `query(
|
|
||||||
$owner:String!,
|
|
||||||
$name:String!,
|
|
||||||
$supportCategory:ID!,
|
|
||||||
$generalCategory:ID!,
|
|
||||||
) {
|
|
||||||
supportDiscussions: repository(owner:$owner, name:$name){
|
|
||||||
discussions(
|
|
||||||
categoryId:$supportCategory,
|
|
||||||
last:50,
|
|
||||||
answered:false,
|
|
||||||
states:[OPEN],
|
|
||||||
) {
|
|
||||||
nodes {
|
|
||||||
id,
|
|
||||||
number,
|
|
||||||
updatedAt
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
generalDiscussions: repository(owner:$owner, name:$name){
|
|
||||||
discussions(
|
|
||||||
categoryId:$generalCategory,
|
|
||||||
last:50,
|
|
||||||
states:[OPEN],
|
|
||||||
) {
|
|
||||||
nodes {
|
|
||||||
id,
|
|
||||||
number,
|
|
||||||
updatedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
const variables = {
|
|
||||||
owner: context.repo.owner,
|
|
||||||
name: context.repo.repo,
|
|
||||||
supportCategory: "DIC_kwDOH31rQM4CRErR",
|
|
||||||
generalCategory: "DIC_kwDOH31rQM4CRErQ"
|
|
||||||
}
|
|
||||||
const result = await github.graphql(query, variables);
|
|
||||||
const combinedDiscussions = [
|
|
||||||
...result.supportDiscussions.discussions.nodes,
|
|
||||||
...result.generalDiscussions.discussions.nodes,
|
|
||||||
]
|
|
||||||
|
|
||||||
console.log(`Checking ${combinedDiscussions.length} open discussions`);
|
|
||||||
|
|
||||||
for (const discussion of combinedDiscussions) {
|
|
||||||
if (new Date(discussion.updatedAt) < cutoff) {
|
|
||||||
console.log(`Closing outdated discussion #${discussion.number} (${discussion.id}), last updated at ${discussion.updatedAt}`);
|
|
||||||
const addCommentMutation = `mutation($discussion:ID!, $body:String!) {
|
|
||||||
addDiscussionComment(input:{discussionId:$discussion, body:$body}) {
|
|
||||||
clientMutationId
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
const commentVariables = {
|
|
||||||
discussion: discussion.id,
|
|
||||||
body: 'This discussion has been automatically closed due to inactivity. See our [contributing guidelines](https://github.com/gethomepage/homepage/blob/main/CONTRIBUTING.md#automatic-repository-maintenance) for more details.',
|
|
||||||
}
|
|
||||||
await github.graphql(addCommentMutation, commentVariables);
|
|
||||||
|
|
||||||
const closeDiscussionMutation = `mutation($discussion:ID!, $reason:DiscussionCloseReason!) {
|
|
||||||
closeDiscussion(input:{discussionId:$discussion, reason:$reason}) {
|
|
||||||
clientMutationId
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
const closeVariables = {
|
|
||||||
discussion: discussion.id,
|
|
||||||
reason: "OUTDATED",
|
|
||||||
}
|
|
||||||
await github.graphql(closeDiscussionMutation, closeVariables);
|
|
||||||
|
|
||||||
await sleep(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close-unsupported-feature-requests:
|
|
||||||
name: 'Close Unsupported Feature Requests'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
function sleep(ms) {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
const CUTOFF_1_DAYS = 180;
|
|
||||||
const CUTOFF_1_COUNT = 10;
|
|
||||||
const CUTOFF_2_DAYS = 365;
|
|
||||||
const CUTOFF_2_COUNT = 20;
|
|
||||||
|
|
||||||
const cutoff1Date = new Date();
|
|
||||||
cutoff1Date.setDate(cutoff1Date.getDate() - CUTOFF_1_DAYS);
|
|
||||||
const cutoff2Date = new Date();
|
|
||||||
cutoff2Date.setDate(cutoff2Date.getDate() - CUTOFF_2_DAYS);
|
|
||||||
|
|
||||||
const query = `query(
|
|
||||||
$owner:String!,
|
|
||||||
$name:String!,
|
|
||||||
$featureRequestsCategory:ID!,
|
|
||||||
) {
|
|
||||||
repository(owner:$owner, name:$name){
|
|
||||||
discussions(
|
|
||||||
categoryId:$featureRequestsCategory,
|
|
||||||
last:100,
|
|
||||||
states:[OPEN],
|
|
||||||
) {
|
|
||||||
nodes {
|
|
||||||
id,
|
|
||||||
number,
|
|
||||||
updatedAt,
|
|
||||||
upvoteCount,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
const variables = {
|
|
||||||
owner: context.repo.owner,
|
|
||||||
name: context.repo.repo,
|
|
||||||
featureRequestsCategory: "DIC_kwDOH31rQM4CRErS"
|
|
||||||
}
|
|
||||||
const result = await github.graphql(query, variables);
|
|
||||||
|
|
||||||
for (const discussion of result.repository.discussions.nodes) {
|
|
||||||
const discussionDate = new Date(discussion.updatedAt);
|
|
||||||
if ((discussionDate < cutoff1Date && discussion.upvoteCount < CUTOFF_1_COUNT) ||
|
|
||||||
(discussionDate < cutoff2Date && discussion.upvoteCount < CUTOFF_2_COUNT)) {
|
|
||||||
console.log(`Closing discussion #${discussion.number} (${discussion.id}), last updated at ${discussion.updatedAt} with votes ${discussion.upvoteCount}`);
|
|
||||||
const addCommentMutation = `mutation($discussion:ID!, $body:String!) {
|
|
||||||
addDiscussionComment(input:{discussionId:$discussion, body:$body}) {
|
|
||||||
clientMutationId
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
const commentVariables = {
|
|
||||||
discussion: discussion.id,
|
|
||||||
body: 'This discussion has been automatically closed due to lack of community support. See our [contributing guidelines](https://github.com/gethomepage/homepage/blob/main/CONTRIBUTING.md#automatic-repository-maintenance) for more details.',
|
|
||||||
}
|
|
||||||
await github.graphql(addCommentMutation, commentVariables);
|
|
||||||
|
|
||||||
const closeDiscussionMutation = `mutation($discussion:ID!, $reason:DiscussionCloseReason!) {
|
|
||||||
closeDiscussion(input:{discussionId:$discussion, reason:$reason}) {
|
|
||||||
clientMutationId
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
const closeVariables = {
|
|
||||||
discussion: discussion.id,
|
|
||||||
reason: "OUTDATED",
|
|
||||||
}
|
|
||||||
await github.graphql(closeDiscussionMutation, closeVariables);
|
|
||||||
|
|
||||||
await sleep(1000);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user