Auto Sync Meeting Notes from Google Docs to GitHub #35
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 Sync Meeting Notes from Google Docs to GitHub | |
| on: | |
| schedule: | |
| # Run daily at 02:00 UTC (adjust as needed) | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| # Allow manual trigger | |
| jobs: | |
| sync_docs: | |
| runs-on: ubuntu-latest | |
| env: | |
| # Variables specific to the meeting-notes-sync workflow | |
| MEETING_NOTES_SYNC_DOC_ID: '1Sr5QS_Z04uPfRbA7PrXr3aPwCRpx7EtsyHq7mp6CnHs' # Google Docs file ID to sync from | |
| MEETING_NOTES_SYNC_TARGET_FILE_PATH: 'meeting-notes/kubeedge-community-meeting-notes.md' # Target file path in the repository | |
| TARGET_BRANCH: 'master' | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # Ensure full history is fetched for diff comparison | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Install Google Drive SDK and GitPython | |
| run: pip install google-auth google-api-python-client GitPython packaging | |
| # Pass service account key as environment variable | |
| # (No need to write service_account.json) | |
| - name: Run Python Sync Script | |
| id: sync | |
| run: python scripts/sync_meeting_notes.py | |
| env: | |
| REPO_OWNER: '${{ github.repository_owner }}' | |
| REPO_NAME: '${{ github.event.repository.name }}' | |
| GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |
| SERVICE_ACCOUNT_JSON: ${{ secrets.MEETING_NOTES_SYNC_SERVICE_ACCOUNT_KEY }} | |
| # Check for document changes | |
| - name: Check for Changes | |
| id: check | |
| shell: bash | |
| run: | | |
| # Check if there are any changes to commit in the staging area (Index) or working directory. | |
| # git status --porcelain outputs the change list in a parseable format. | |
| # wc -l counts lines: if lines > 0, there are changes. | |
| CHANGE_COUNT=$(git status --porcelain | wc -l) | |
| if [ $CHANGE_COUNT -gt 0 ]; then | |
| # Changes exist (including new documents) | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| echo "Detected $CHANGE_COUNT changes (including new files). Proceeding to create PR." | |
| # Optional: print out the change list | |
| git status --porcelain | |
| else | |
| # No changes | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| echo "No file changes detected. Skipping PR creation." | |
| fi | |
| - name: Commit and Create Pull Request | |
| if: steps.check.outputs.has_changes == 'true' | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "docs: update ${{ env.MEETING_NOTES_SYNC_TARGET_FILE_PATH }} via GitHub Action." | |
| committer: >- | |
| ${{ github.actor == 'github-actions[bot]' && 'github-actions[bot] <[email protected]>' || format('{0} <{0}@users.noreply.github.com>', github.actor) }} | |
| author: >- | |
| ${{ github.actor == 'github-actions[bot]' && 'github-actions[bot] <[email protected]>' || format('{0} <{0}@users.noreply.github.com>', github.actor) }} | |
| signoff: true | |
| branch: 'action-sync-${{ github.event.repository.name }}-${{ github.sha }}' | |
| base: ${{ env.TARGET_BRANCH }} | |
| title: '[Docs] Auto Sync: ${{ env.MEETING_NOTES_SYNC_TARGET_FILE_PATH }}' | |
| body: | | |
| This PR was automatically generated by GitHub Actions to sync Google Docs. | |
| - **Source Doc ID:** `${{ env.MEETING_NOTES_SYNC_DOC_ID }}` | |
| - **File:** `${{ env.MEETING_NOTES_SYNC_TARGET_FILE_PATH }}` |