Skip to content

Commit

Permalink
chore: fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Firgrep committed Sep 21, 2024
2 parents 0e4e919 + 3e89dc8 commit 2cd5cf1
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 32 deletions.
34 changes: 10 additions & 24 deletions .github/workflows/verify_formatting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,17 @@ on:
pull_request:
branches: [main]

permissions:
contents: read

jobs:
formatting:
runs-on: ubuntu-latest
steps:

- name: Generate COG token
id: create_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.COG_APP_ID }}
private_key: ${{ secrets.COG_PRIVATE_KEY }}

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.create_token.outputs.token }}


- name: Set up Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -33,20 +26,13 @@ jobs:
PRETTIER_VERSION=$(grep -m 1 'prettier' package-lock.json | cut -d '"' -f 4 | cut -c 2-)
echo $PRETTIER_VERSION
- name: Run Prettier (specific version)
- name: Check formatting
run: |
npx --yes prettier@$PRETTIER_VERSION --check --config .prettierrc --write .
npx --yes prettier@$PRETTIER_VERSION --check --config .prettierrc .
- name: Check for Prettier Changes
id: prettier-changes
- name: Fail if formatting check failed
if: failure()
run: |
echo "has_changes=$(git status --porcelain | wc -l)" >> $GITHUB_OUTPUT
- name: Add and commit changes
uses: EndBug/add-and-commit@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: 'ci: format code [automated action on behalf of ${{ github.event.pull_request.user.login }}]'
if: steps.prettier-changes.outputs.has_changes != '0'
echo "Formatting check failed. Please format your code according to the project's Prettier configuration."
exit 1
6 changes: 2 additions & 4 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "0.2",
"ignorePaths": ["node_modules", "dist", "build", "out", "public", "package-lock.json", "package.json"],
"ignorePaths": ["package.json", "package-lock.json""node_modules", "dist", "build", "out", "public", "package-lock.json", "package.json"],
"dictionaryDefinitions": [],
"dictionaries": [],
"words": [
Expand Down Expand Up @@ -58,9 +58,7 @@
"Wissenschaft",
"Zusätze"
],
"enableFiletypes": [
"mdx"
],
"enableFiletypes": ["mdx"],
"ignoreWords": [
"biblatex",
"datetime",
Expand Down
54 changes: 54 additions & 0 deletions logs/deprecated/run_formatting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Run formatting on command

on:
issue_comment:
types: [created]

permissions:
contents: write

jobs:
run-prettier:
if: ${{ github.event.comment.body == '/run-format' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.issue.pull_request.head.ref }}
repository: ${{ github.event.issue.pull_request.head.repo.full_name }}


- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Get Prettier version from package-lock.json
run: |
PRETTIER_VERSION=$(grep -m 1 'prettier' package-lock.json | cut -d '"' -f 4 | cut -c 2-)
echo $PRETTIER_VERSION

- name: Run Prettier (specific version)
run: |
npx --yes prettier@$PRETTIER_VERSION --check --config .prettierrc --write .

- name: Check for Prettier Changes
id: prettier-changes
run: |
echo "has_changes=$(git status --porcelain | wc -l)" >> $GITHUB_OUTPUT

- name: Add and commit changes
uses: EndBug/add-and-commit@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: 'ci: format code [automated action on behalf of ${{ github.event.comment.user.login }}]'
if: steps.prettier-changes.outputs.has_changes != '0'

# - name: Push changes
# if: success()
# uses: ad-m/github-push-action@v0.8.0
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: ${{ github.event.issue.pull_request.head.ref }}
64 changes: 64 additions & 0 deletions logs/deprecated/verify_formatting_old.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Verify formatting

on:
workflow_dispatch:
pull_request:
branches: [main]

permissions:
contents: write

jobs:
formatting:
runs-on: ubuntu-latest
steps:

- name: Generate COG token
continue-on-error: true
id: create_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.COG_APP_ID }}
private_key: ${{ secrets.COG_PRIVATE_KEY }}

- name: Checkout with app
uses: actions/checkout@v4
if: steps.create_token.outcome == 'success'
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.create_token.outputs.token }}

- name: Checkout with token
uses: actions/checkout@v4
if: steps.create_token.outcome == 'failure'
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GH_PAT }}

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Get Prettier version from package-lock.json
run: |
PRETTIER_VERSION=$(grep -m 1 'prettier' package-lock.json | cut -d '"' -f 4 | cut -c 2-)
echo $PRETTIER_VERSION

- name: Run Prettier (specific version)
run: |
npx --yes prettier@$PRETTIER_VERSION --check --config .prettierrc --write .

- name: Check for Prettier Changes
id: prettier-changes
run: |
echo "has_changes=$(git status --porcelain | wc -l)" >> $GITHUB_OUTPUT

- name: Add and commit changes
uses: EndBug/add-and-commit@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: 'ci: format code [automated action on behalf of ${{ github.event.pull_request.user.login }}]'
if: steps.prettier-changes.outputs.has_changes != '0'

9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2cd5cf1

Please sign in to comment.