|
| 1 | +name: SharePoint Document Sync |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + sync_mode: |
| 9 | + description: "Sync mode override (full = upload all files, auto = git-diff)" |
| 10 | + required: false |
| 11 | + default: "full" |
| 12 | + type: choice |
| 13 | + options: |
| 14 | + - full |
| 15 | + - auto |
| 16 | + |
| 17 | +permissions: |
| 18 | + id-token: write # Required for OIDC token exchange |
| 19 | + contents: read # Required to read repo files |
| 20 | + |
| 21 | +env: |
| 22 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + sync: |
| 26 | + name: Sync documents to SharePoint |
| 27 | + runs-on: ubuntu-latest |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout repository |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 # Full history for git-diff delta detection |
| 34 | + |
| 35 | + - name: Determine merge base |
| 36 | + id: merge-base |
| 37 | + run: | |
| 38 | + # If manually triggered with "full" mode, skip SHA detection |
| 39 | + if [ "${{ github.event.inputs.sync_mode }}" = "full" ]; then |
| 40 | + echo "base-sha=" >> "$GITHUB_OUTPUT" |
| 41 | + echo "head-sha=" >> "$GITHUB_OUTPUT" |
| 42 | + else |
| 43 | + BASE_SHA=$(git rev-parse HEAD~1 2>/dev/null || echo "") |
| 44 | + HEAD_SHA=$(git rev-parse HEAD) |
| 45 | + echo "base-sha=${BASE_SHA}" >> "$GITHUB_OUTPUT" |
| 46 | + echo "head-sha=${HEAD_SHA}" >> "$GITHUB_OUTPUT" |
| 47 | + fi |
| 48 | +
|
| 49 | + # SENSITIVE INFORMATION: AZURE_CLIENT_ID and AZURE_TENANT_ID are stored as |
| 50 | + # GitHub Encrypted Secrets. They are UUIDs (not credentials), but reveal |
| 51 | + # infrastructure identity. Never hardcode them — always reference via secrets. |
| 52 | + - name: Azure Login (OIDC) |
| 53 | + uses: azure/login@v2 |
| 54 | + with: |
| 55 | + client-id: ${{ secrets.AZURE_CLIENT_ID }} # SENSITIVE INFORMATION: App Registration Client ID |
| 56 | + tenant-id: ${{ secrets.AZURE_TENANT_ID }} # SENSITIVE INFORMATION: Entra ID Tenant ID |
| 57 | + allow-no-subscriptions: true |
| 58 | + |
| 59 | + - name: Sync to SharePoint |
| 60 | + uses: ./actions/sharepoint-sync |
| 61 | + with: |
| 62 | + config-path: .github/sharepoint-sync.yml |
| 63 | + base-sha: ${{ steps.merge-base.outputs.base-sha }} |
| 64 | + head-sha: ${{ steps.merge-base.outputs.head-sha }} |
0 commit comments