Final Testing #9
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: Auto Docs to Blog | |
| on: | |
| push: | |
| paths: | |
| - '**.java' | |
| jobs: | |
| generate-docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout DSA repo | |
| uses: actions/checkout@v3 | |
| - name: Get changed files | |
| id: files | |
| run: | | |
| if [ -z "${{ github.event.before }}" ]; then | |
| echo "files<<EOF" >> $GITHUB_OUTPUT | |
| git diff --name-only HEAD~1 ${{ github.sha }} | grep '\.java$' || true >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| else | |
| echo "files<<EOF" >> $GITHUB_OUTPUT | |
| git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '\.java$' || true >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Checkout Blog repo | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: atomhudson/atomhudsoneng-blog | |
| path: blog | |
| token: ${{ secrets.BLOG_PAT }} # must be set in DSA repo secrets! | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '20' | |
| - name: Install deps | |
| run: npm install openai | |
| - name: Generate Docs | |
| run: node .github/scripts/generate-blog.js | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| BLOG_PATH: blog/content/posts | |
| GITHUB_REPO: ${{ github.repository }} | |
| COMMIT_SHA: ${{ github.sha }} | |
| FILES: ${{ steps.files.outputs.files }} | |
| - name: Commit & Push to blog | |
| run: | | |
| cd blog | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| git add content/posts | |
| git commit -m "Auto docs update from ${{ github.repository }} @ ${{ github.sha }}" || echo "No changes to commit" | |
| git push |