Code & Beyond: Eugene’s Dev Journey

Back

아래 코드는 SSG, 정적블로그 작업중에 만들게 된 코드입니다. 블로그에 마크다운(md, mdx) 글을 작성한 이후, PR 을 생성하고 병합할때 동작하도록 만든 코드입니다.

create-gist.yaml
name: Create Gist from Markdown with Programming Language Extension

on:
  pull_request:
    branches:
      - main
    types: 
      - closed
    paths:
      - '**/*.*.md' # 예: debounce.js.md
      - '**/*.*.mdx' # 예: debounce.js.mdx

jobs:
  create-gist:
    runs-on: ubuntu-latest

    if: github.event.pull_request.merged == true
    steps:
      - name: Check out repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0 # 전체 히스토리 가져오기
          sparse-checkout: |
            'src/content'
            '.github/workflows/create-gist.mjs'

      - name: Set up Node.js
        uses: actions/setup-node@v4
        # with:
        # node-version: '22'  # 최신 LTS 버전으로 업데이트

      - name: Install dependencies
        run: npm install @octokit/rest gray-matter process

      - name: Create Gists
        env:
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
        run: node .github/workflows/create-gist.mjs
yaml
GitHub Workflow에서 PR(Pull Request)가 병합(merge)될때 동작하게 만들기
https://eugenejeon.me/blog/dev-github-workflow-pr-pull-request-merge/
Author Eugene
Published at 2025년 3월 1일