Build and Deploy #163
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Build and Deploy" | |
| on: | |
| repository_dispatch: | |
| types: [RUN_WORKFLOW_DISPATCH] | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '30 5 * * *' | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 1 | |
| - name: Clean Directory | |
| run: | | |
| for file in assets/img/* | |
| do | |
| if [[ $file != "assets/img/favicons" ]] | |
| then | |
| rm -rf "$file" | |
| fi | |
| done | |
| rm -rf _posts/* | |
| - name: Setup Node | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: "17" | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Run Notion Importer | |
| run: node _scripts/notion-import.js | |
| env: | |
| NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }} | |
| DATABASE_ID: ${{ secrets.DATABASE_ID }} | |
| - name: Auto-commit changes | |
| uses: stefanzweifel/git-auto-commit-action@v4 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| commit_message: "[배포] Notion 변경 사항 저장" | |
| branch: main | |
| commit_user_name: importer-bot 🤖 | |
| commit_user_email: actions@github.com | |
| commit_author: importer-bot 🤖 <actions@github.com> | |
| - name: Setup Pages | |
| id: pages | |
| uses: actions/configure-pages@v3 | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.1' | |
| bundler-cache: true | |
| - name: Build site | |
| run: bundle exec jekyll b -d "_site${{ steps.pages.outputs.base_path }}" | |
| env: | |
| JEKYLL_ENV: "production" | |
| - name: Upload site artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: "_site${{ steps.pages.outputs.base_path }}" | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |