<commit_before>name: Deploy Site

on:
  push:
    branches:
      - master
  schedule:
    - cron: '0 0 1/4 * *'   # every 4 days

jobs:
  deploy_site:
    name: "Deploy Generated Site"
    runs-on: ubuntu-latest
    needs: [build_site, check_spelling]

    steps:
    - name: "Download Generated Site"
      uses: actions/download-artifact@v1
      with:
        name: generated_site

    - name: Setup SSH Keys and known_hosts
      run: |
          mkdir -p ~/.ssh
          ssh-keyscan github.com >> ~/.ssh/known_hosts
          ssh-agent -a $SSH_AUTH_SOCK > /dev/null
          ssh-add - <<< "$deploy_key"
      env:
        SSH_AUTH_SOCK: /tmp/ssh_agent.sock
        deploy_key: ${{ secrets.DEPLOY_SSH_KEY }}

    - name: "Clone blog_os_deploy Repo"
      run: git clone <EMAIL>:phil-opp/blog_os_deploy.git --branch gh-pages
      env:
        SSH_AUTH_SOCK: /tmp/ssh_agent.sock

    - name: "Set Up Git Identity"
      run: |
        git config --local user.name "GitHub Actions Deploy"
        git config --local user.email "<EMAIL>"
      working-directory: "blog_os_deploy"

    - name: "Delete Old Content"
      run: "rm -r ./*"
      working-directory: "blog_os_deploy"

    - name: "Add New Content"
      run: cp -r generated_site/* blog_os_deploy

    - name: "Commit New Content"
      run: |
        git add .
        git commit --allow-empty -m "Deploy ${GITHUB_SHA}

        Deploy of commit https://github.com/phil-opp/blog_os/commit/${GITHUB_SHA}"
      working-directory: "blog_os_deploy"

    - name: "Show Changes"
      run: "git show"
      working-directory: "blog_os_deploy"

    - name: "Push Changes"
      run: "git push"
      working-directory: "blog_os_deploy"
      env:
        SSH_AUTH_SOCK: /tmp/ssh_agent.sock

  # TODO: Reuse artifact by `build-site` workflow when
  # https://github.com/actions/download-artifact/issues/3 is resolved.
  build_site:
    name: "Zola Build"
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1

    - name: 'Download Zola'
      run: curl -sL https://github.com/getzola/zola/releases/download/v0.7.0/zola-v0.7.0-x86_64-unknown-linux-gnu.tar.gz | tar zxv
    - name: "Install Python Tools"
      run: python -m pip install --upgrade pip setuptools wheel
    - name: 'Install Python Libraries'
      run: python -m pip install --user -r requirements.txt
      working-directory: "blog"

    - name: "Run before_build.py script"
      run: python before_build.py
      working-directory: "blog"
    - name: "Build Site"
      run: ../zola build
      working-directory: "blog"

    - name: Upload Generated Site
      uses: actions/upload-artifact@v1.0.0
      with:
        name: generated_site
        path: blog/public

  check_spelling:
    name: "Check Spelling"
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1

    - run: curl -L https://git.io/misspell | bash
      name: "Install misspell"
    - run: bin/misspell -error blog/content
      name: "Check for common typos"
<commit_msg>Use ::set-env command instead of repeating env variable<commit_after>name: Deploy Site

on:
  push:
    branches:
      - master
  schedule:
    - cron: '0 0 1/4 * *'   # every 4 days

jobs:
  deploy_site:
    name: "Deploy Generated Site"
    runs-on: ubuntu-latest
    needs: [build_site, check_spelling]

    steps:
    - name: "Download Generated Site"
      uses: actions/download-artifact@v1
      with:
        name: generated_site

    - name: Setup SSH Keys and known_hosts
      run: |
          mkdir -p ~/.ssh
          ssh-keyscan github.com >> ~/.ssh/known_hosts
          ssh-agent -a $SSH_AUTH_SOCK > /dev/null
          ssh-add - <<< "$deploy_key"
          echo ::set-env name=SSH_AUTH_SOCK::$SSH_AUTH_SOCK
      env:
        SSH_AUTH_SOCK: /tmp/ssh_agent.sock
        deploy_key: ${{ secrets.DEPLOY_SSH_KEY }}

    - name: "Clone blog_os_deploy Repo"
      run: git clone <EMAIL>:phil-opp/blog_os_deploy.git --branch gh-pages

    - name: "Set Up Git Identity"
      run: |
        git config --local user.name "<NAME>"
        git config --local user.email "<EMAIL>"
      working-directory: "blog_os_deploy"

    - name: "Delete Old Content"
      run: "rm -r ./*"
      working-directory: "blog_os_deploy"

    - name: "Add New Content"
      run: cp -r generated_site/* blog_os_deploy

    - name: "Commit New Content"
      run: |
        git add .
        git commit --allow-empty -m "Deploy ${GITHUB_SHA}

        Deploy of commit https://github.com/phil-opp/blog_os/commit/${GITHUB_SHA}"
      working-directory: "blog_os_deploy"

    - name: "Show Changes"
      run: "git show"
      working-directory: "blog_os_deploy"

    - name: "Push Changes"
      run: "git push"
      working-directory: "blog_os_deploy"

  # TODO: Reuse artifact by `build-site` workflow when
  # https://github.com/actions/download-artifact/issues/3 is resolved.
  build_site:
    name: "Zola Build"
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1

    - name: 'Download Zola'
      run: curl -sL https://github.com/getzola/zola/releases/download/v0.7.0/zola-v0.7.0-x86_64-unknown-linux-gnu.tar.gz | tar zxv
    - name: "Install Python Tools"
      run: python -m pip install --upgrade pip setuptools wheel
    - name: 'Install Python Libraries'
      run: python -m pip install --user -r requirements.txt
      working-directory: "blog"

    - name: "Run before_build.py script"
      run: python before_build.py
      working-directory: "blog"
    - name: "Build Site"
      run: ../zola build
      working-directory: "blog"

    - name: Upload Generated Site
      uses: actions/upload-artifact@v1.0.0
      with:
        name: generated_site
        path: blog/public

  check_spelling:
    name: "Check Spelling"
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1

    - run: curl -L https://git.io/misspell | bash
      name: "Install misspell"
    - run: bin/misspell -error blog/content
      name: "Check for common typos"

{'fraction_non_alphanumeric': 0.11733244191876985, 'fraction_numerical': 0.0073541701487548055, 'mean_word_length': 2.2504073872895165, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2469630', 'n_tokens_mistral': 2132, 'n_tokens_neox': 1997, 'n_words': 518}