Skip to content

Added lonelyguy12 in contributors #178

Added lonelyguy12 in contributors

Added lonelyguy12 in contributors #178

Workflow file for this run

name: CI JSON Checker
on:
pull_request:
branches: [main]
paths:
- "contributors/*"
workflow_dispatch:
concurrency:
group: ${{ github.ref }}-ci-validator
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
GH_TOKEN: ${{ secrets.FA_TOKEN }}
steps:
- uses: actions/checkout@v4
- run: npm install
- name: Fetch PR information
env:
GH_TOKEN: ${{ github.token }}
if: github.event_name == 'pull_request'
run: |
echo "PR_AUTHOR=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV
echo "PR_AUTHOR_ID=${{ github.event.pull_request.user.id }}" >> $GITHUB_ENV
LABELS=$(gh api --jq '[.labels[].name]' /repos/{owner}/{repo}/pulls/${{ github.event.number }})
echo "PR_LABELS=$LABELS" >> $GITHUB_ENV
# login
# echo "${GITHUB_TOKEN}" | gh auth login --with-token
FILES=$(gh api --jq '[.[] | select(.status != "removed") | .filename]' /repos/{owner}/{repo}/pulls/${{ github.event.number }}/files)
echo "CHANGED_FILES=$FILES" >> $GITHUB_ENV
REMOVED_FILE_DATA=$(gh api --jq '[.[] | select(.status == "removed") | {name: .filename, data: .patch}]' /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files)
echo "DELETED_FILES=$REMOVED_FILE_DATA" >> $GITHUB_ENV
- name: Json Validation
id: json_validation
run: |
npx ava tests/*.test.js
# - name: Post PR on failure
# if: failure()
# run: |
# failed_tests=$(grep '^not ok' ava.tap || true)
# echo "FA_FAILED=$failed_tests" >> $GITHUB_ENV
# - name: Post PR comment on failure
# if: failure()
# uses: peter-evans/create-or-update-comment@v5
# with:
# issue-number: ${{ github.event.number }}
# body: |
# ❌ Validation failed! See test output below:
# ```
# ${{ env.FA_FAILED }}
# ```
# env:
# GITHUB_TOKEN: ${{ secrets.FA_TOKEN }}
# run: |
# gh auth logout
# echo "${GITHUB_TOKEN}" | gh auth login -p https --with-token
# failed_tests=$(grep '^not ok' ava.tap || true)
# echo "❌ Found failed tests:"
# echo "$failed_tests"
# gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
# -H "Accept: application/vnd.github+json" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# -f body="$(cat <<EOF
# ❌ Validation failed! See test output below:
# \`\`\`
# $failed_tests
# \`\`\`
# EOF
# )" \
# --method POST
# - name: Congratulate and auto-merge on success
# env:
# GITHUB_TOKEN: ${{ secrets.FA_TOKEN }}
# if: success()
# run: |
# gh auth logout
# echo "${GITHUB_TOKEN}" | gh auth login -p https --with-token
# # comment
# gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
# -H "Accept: application/vnd.github+json" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# -f body="$(cat <<EOF
# 🎉 Congratulations! All checks passed. Your PR will be auto-merged.
# EOF
# )" \
# --method POST
# # label
# gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
# -f labels='["ready to merge"]' \
# --method POST
# # auto merge
# gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge \
# -f merge_method="squash" \
# -f commit_title="Merge PR #${{ github.event.pull_request.number }}" \
# -f commit_message="Automated merging by workflow" \
# --method PUT