diff --git a/.github/workflows/generate_pr_from_issue.yaml b/.github/workflows/generate_pr_from_issue.yaml index 8f09bf97..559373bc 100644 --- a/.github/workflows/generate_pr_from_issue.yaml +++ b/.github/workflows/generate_pr_from_issue.yaml @@ -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 "yosuke.akatsuka@gmail.com" - 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 "yosuke.akatsuka@gmail.com" + 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 }}" diff --git a/.github/workflows/generate_site_and_deploy.yaml b/.github/workflows/generate_site_and_deploy.yaml index 3d194767..f96e4be3 100644 --- a/.github/workflows/generate_site_and_deploy.yaml +++ b/.github/workflows/generate_site_and_deploy.yaml @@ -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 diff --git a/.github/workflows/notify_long_time_no_see.yaml b/.github/workflows/notify_long_time_no_see.yaml index fcb67ca0..4d250c6e 100644 --- a/.github/workflows/notify_long_time_no_see.yaml +++ b/.github/workflows/notify_long_time_no_see.yaml @@ -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/**' @@ -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 }}