generate-podcast #15
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: generate-podcast | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| debug: | |
| description: 'Run in debug mode' | |
| required: false | |
| default: 'false' | |
| type: boolean | |
| # every morning at 4am EST | |
| schedule: | |
| - cron: '0 9 * * *' # 4am EST | |
| permissions: | |
| contents: read | |
| actions: write # for caching | |
| env: | |
| NODE_VERSION: 23.6.0 | |
| PNPM_VERSION: 9.15.4 | |
| COVERED_STORIES_CACHE_KEY: ${{ github.ref }}-covered-stories | |
| jobs: | |
| podcast: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install ffmpeg | |
| run: sudo apt-get update && sudo apt-get install -y ffmpeg | |
| - name: Node setup | |
| uses: ./.github/actions/setup | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| pnpm-version: ${{ env.PNPM_VERSION }} | |
| pnpm-install-cache-key: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| - name: Create cache directory | |
| run: mkdir ./cache | |
| # Restore cache from cache/covered-stories | |
| - name: Restore covered-stories | |
| id: cache-restore | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ./cache/covered-stories | |
| key: ${{ env.COVERED_STORIES_CACHE_KEY }} | |
| - run: pnpm start | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| ELEVEN_LABS_API_KEY: ${{ secrets.ELEVEN_LABS_API_KEY }} | |
| DEBUG: ${{ github.event.inputs.debug }} | |
| # Use `elevenlabs` on main, else `openai` | |
| VOICE_SERVICE: ${{ github.ref == 'refs/heads/main' && 'elevenlabs' || 'openai' }} | |
| - name: Delete Previous Cache | |
| if: ${{ steps.cache-restore.outputs.cache-hit }} | |
| continue-on-error: true | |
| run: | | |
| gh extension install actions/gh-actions-cache | |
| gh actions-cache delete "${{ env.COVERED_STORIES_CACHE_KEY }}" --confirm | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Cache cache/covered-stories for next run | |
| - name: Cache covered-stories | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: ./cache/covered-stories | |
| key: ${{ env.COVERED_STORIES_CACHE_KEY }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: output | |
| path: output | |
| retention-days: 1 | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: covered-stories | |
| path: ./cache/covered-stories | |
| retention-days: 7 | |
| - name: Log covered-stories and show-notes | |
| run: | | |
| set -ex | |
| cat cache/covered-stories | |
| cat output/show-notes.txt |