Skip to content

Commit

Permalink
Merge pull request #250 from pankona/fmt-yaml
Browse files Browse the repository at this point in the history
Format YAML with yamlfmt and dprint
  • Loading branch information
pankona authored Feb 6, 2024
2 parents 2ae065b + 2e5a376 commit 93727e0
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 137 deletions.
90 changes: 45 additions & 45 deletions .github/workflows/generate_pr_from_issue.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,48 @@ jobs:
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
# Needed to specify token for checkout phase, only in push phase is too late
# https://github.com/orgs/community/discussions/27072#discussioncomment-3254515
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: debug logging for git remotes
run: git remote -v
- name: Normalize issue title
id: normalizer
env:
ISSUE_TITLE: ${{ github.event.issue.title }}
run: |
title="$ISSUE_TITLE"
title="${title//\[*\]/}"
title=`echo $title | xargs`
echo "title=${title// /-}" | tee -a "$GITHUB_OUTPUT"
- name: setup go
uses: actions/setup-go@v5
with:
go-version-file: 'tool/go.mod'
cache-dependency-path: 'tool/go.sum'
- name: install articlegen
run: |
cd ./tool/articlegen
go install .
- name: install makepr
run: |
cd ./tool/makepr
go install .
- name: commit
run: |
GITHUB_TOKEN=${TOKEN} articlegen --issue-num=${{ github.event.issue.number }} > 'content/posts/${{ steps.normalizer.outputs.title }}.md'
git config user.email "[email protected]"
git config user.name "pankona"
git switch '${{ steps.normalizer.outputs.title }}' || git switch -c '${{ steps.normalizer.outputs.title }}'
git add 'content/posts/${{ steps.normalizer.outputs.title }}.md'
git commit -m "add post ${{ steps.normalizer.outputs.title }}"
- name: push
env:
GH_TOKEN: ${{ github.token }}
# "--force-with-lease" will not fit for upserting
run: |
pr_number="$(gh pr list --author "@me" --head '${{ steps.normalizer.outputs.title }}' --state open --json number --jq 'map(.number)[0]')"
git push --set-upstream origin "${{ steps.normalizer.outputs.title }}" --force
GITHUB_TOKEN=${TOKEN} makepr --base="main" --head='${{ steps.normalizer.outputs.title }}' --pr_number="${pr_number:=0}" --body="Resolves: ${{ github.event.issue.html_url }}"
- uses: actions/checkout@v4
with:
# Needed to specify token for checkout phase, only in push phase is too late
# https://github.com/orgs/community/discussions/27072#discussioncomment-3254515
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: debug logging for git remotes
run: git remote -v
- name: Normalize issue title
id: normalizer
env:
ISSUE_TITLE: ${{ github.event.issue.title }}
run: |
title="$ISSUE_TITLE"
title="${title//\[*\]/}"
title=`echo $title | xargs`
echo "title=${title// /-}" | tee -a "$GITHUB_OUTPUT"
- name: setup go
uses: actions/setup-go@v5
with:
go-version-file: 'tool/go.mod'
cache-dependency-path: 'tool/go.sum'
- name: install articlegen
run: |
cd ./tool/articlegen
go install .
- name: install makepr
run: |
cd ./tool/makepr
go install .
- name: commit
run: |
GITHUB_TOKEN=${TOKEN} articlegen --issue-num=${{ github.event.issue.number }} > 'content/posts/${{ steps.normalizer.outputs.title }}.md'
git config user.email "[email protected]"
git config user.name "pankona"
git switch '${{ steps.normalizer.outputs.title }}' || git switch -c '${{ steps.normalizer.outputs.title }}'
git add 'content/posts/${{ steps.normalizer.outputs.title }}.md'
git commit -m "add post ${{ steps.normalizer.outputs.title }}"
- name: push
env:
GH_TOKEN: ${{ github.token }}
# "--force-with-lease" will not fit for upserting
run: |
pr_number="$(gh pr list --author "@me" --head '${{ steps.normalizer.outputs.title }}' --state open --json number --jq 'map(.number)[0]')"
git push --set-upstream origin "${{ steps.normalizer.outputs.title }}" --force
GITHUB_TOKEN=${TOKEN} makepr --base="main" --head='${{ steps.normalizer.outputs.title }}' --pr_number="${pr_number:=0}" --body="Resolves: ${{ github.event.issue.html_url }}"
82 changes: 41 additions & 41 deletions .github/workflows/generate_site_and_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,47 @@ jobs:
# Keep same version with `make deps`
HUGO_VERSION: 0.122.0
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass Embedded
run: sudo snap install dart-sass-embedded
- name: Checkout
uses: actions/checkout@v4
# Required go env because hugo module depends on it
- name: Cache hugo resources
uses: actions/cache@v4
with:
path: /home/runner/.cache/hugo_cache
key: ${{ runner.os }}-hugo-v${{ env.HUGO_VERSION }}-hugomod-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-hugo-v${{ env.HUGO_VERSION }}-hugomod-
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo --panicOnWarning \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
if: github.event.sender.login == 'pankona'
uses: actions/upload-pages-artifact@v3
with:
path: ./public
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass Embedded
run: sudo snap install dart-sass-embedded
- name: Checkout
uses: actions/checkout@v4
# Required go env because hugo module depends on it
- name: Cache hugo resources
uses: actions/cache@v4
with:
path: /home/runner/.cache/hugo_cache
key: ${{ runner.os }}-hugo-v${{ env.HUGO_VERSION }}-hugomod-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-hugo-v${{ env.HUGO_VERSION }}-hugomod-
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo --panicOnWarning \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
if: github.event.sender.login == 'pankona'
uses: actions/upload-pages-artifact@v3
with:
path: ./public
deploy:
environment:
name: github-pages
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint
on:
pull_request:
workflow_dispatch:

jobs:
typo:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/[email protected]
with:
# https://github.com/crate-ci/typos/issues/779#issuecomment-1635761199
files: |
.
.github
.vscode
format:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup go to install yamlfmt
uses: actions/setup-go@v5
- name: Install yamlfmt
run: |
go install github.com/google/yamlfmt/cmd/[email protected]
- uses: dprint/[email protected]
with:
dprint-version: 0.45.0
66 changes: 33 additions & 33 deletions .github/workflows/notify_long_time_no_see.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: notify_long_time_no_see
on:
workflow_dispatch:
schedule:
- cron: '0 22 * * *'
- cron: '0 22 * * *'
pull_request:
paths:
- 'tool/sincelastcommit/**'
Expand All @@ -13,36 +13,36 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4
- name: Checkout articles in head ref to collect git info
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
path: tmp/head
- name: setup go
uses: actions/setup-go@v5
with:
go-version-file: 'tool/go.mod'
cache-dependency-path: 'tool/go.sum'
- name: install sincelastcommit
run: go install -C ./tool/sincelastcommit
- name: Logging the collection items are actually head
run: |
cd tmp/head
git log -- content/posts
- name: check since last commit
run: |
cd tmp/head
days="$(sincelastcommit)"
echo "SINCE_LAST_COMMIT=${days}" | tee -a "$GITHUB_ENV"
- name: Slack Notification
if: env.SINCE_LAST_COMMIT >= 7 && github.event_name != 'pull_request'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: notification
SLACK_MESSAGE: "最後のブログ更新から ${{ env.SINCE_LAST_COMMIT }} 日過ぎています。"
SLACK_USERNAME: pankona
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- name: Checkout codebase
uses: actions/checkout@v4
- name: Checkout articles in head ref to collect git info
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
path: tmp/head
- name: setup go
uses: actions/setup-go@v5
with:
go-version-file: 'tool/go.mod'
cache-dependency-path: 'tool/go.sum'
- name: install sincelastcommit
run: go install -C ./tool/sincelastcommit
- name: Logging the collection items are actually head
run: |
cd tmp/head
git log -- content/posts
- name: check since last commit
run: |
cd tmp/head
days="$(sincelastcommit)"
echo "SINCE_LAST_COMMIT=${days}" | tee -a "$GITHUB_ENV"
- name: Slack Notification
if: env.SINCE_LAST_COMMIT >= 7 && github.event_name != 'pull_request'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: notification
SLACK_MESSAGE: "最後のブログ更新から ${{ env.SINCE_LAST_COMMIT }} 日過ぎています。"
SLACK_USERNAME: pankona
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

18 changes: 0 additions & 18 deletions .github/workflows/typos.yml

This file was deleted.

12 changes: 12 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"excludes": [],
"exec": {
"commands": [{
"command": "yamlfmt -in -formatter retain_line_breaks=true",
"exts": ["yaml", "yml"]
}]
},
"plugins": [
"https://plugins.dprint.dev/exec-0.4.4.json@c207bf9b9a4ee1f0ecb75c594f774924baf62e8e53a2ce9d873816a408cecbf7"
]
}
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
peco
typos
dprint
yamlfmt
imagemagick
actionlint
nil
Expand Down

0 comments on commit 93727e0

Please sign in to comment.