mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-16 23:56:54 -04:00
67 lines
2.5 KiB
YAML
67 lines
2.5 KiB
YAML
name: Update Error Database
|
|
|
|
on:
|
|
discussion:
|
|
types: [created, edited, deleted, category_changed, answered, unanswered]
|
|
discussion_comment:
|
|
types: [created, edited, deleted]
|
|
|
|
jobs:
|
|
update-error-db:
|
|
runs-on: ubuntu-latest
|
|
if: github.event.discussion.category.name == 'Errors'
|
|
steps:
|
|
- name: Query Discussion Data
|
|
if: github.event_name == 'discussion_comment' || github.event_name == 'discussion' && github.event.action != 'deleted'
|
|
id: query-data
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
with:
|
|
script: |
|
|
const query = `query ($owner: String!, $name: String!, $discussionNumber: Int!) {
|
|
repository(owner: $owner, name: $name) {
|
|
discussion(number: $discussionNumber) {
|
|
id
|
|
upvoteCount
|
|
title
|
|
url
|
|
answer {
|
|
url
|
|
upvoteCount
|
|
}
|
|
comments {
|
|
totalCount
|
|
}
|
|
}
|
|
}
|
|
}`;
|
|
const variables = {
|
|
owner: context.repo.owner,
|
|
name: context.repo.repo,
|
|
discussionNumber: context.payload.discussion.number
|
|
}
|
|
return await github.graphql(query, variables)
|
|
- name: Get Gist
|
|
id: get-gist
|
|
uses: andymckay/get-gist-action@cf3bc8164af24126f7e5979eb6d3dc0c12309bd1 # not_tagged
|
|
with:
|
|
gistURL: https://gist.github.com/cryptobot/accba9fb9555e7192271b85606f97230
|
|
- name: Merge Error Code Data
|
|
run: |
|
|
jq -c '.' ${{ steps.get-gist.outputs.file }} > original.json
|
|
if [ ! -z "$DISCUSSION" ]
|
|
then
|
|
echo $DISCUSSION | jq -c '.repository.discussion | .comments = .comments.totalCount | {(.id|tostring) : .}' > new.json
|
|
jq -s '.[0] * .[1]' original.json new.json > merged.json
|
|
else
|
|
cat original.json | jq 'del(.[] | select(.url=="https://github.com/cryptomator/cryptomator/discussions/${{ github.event.discussion.number }}"))' > merged.json
|
|
fi
|
|
env:
|
|
DISCUSSION: ${{ steps.query-data.outputs.result }}
|
|
- name: Patch Gist
|
|
uses: exuanbo/actions-deploy-gist@47697fceaeea2006a90594ee24eb9cd0a1121ef8 # v1.1.4
|
|
with:
|
|
token: ${{ secrets.CRYPTOBOT_GIST_TOKEN }}
|
|
gist_id: accba9fb9555e7192271b85606f97230
|
|
gist_file_name: errorcodes.json
|
|
file_path: merged.json
|