|
| 1 | +name: "[Automation] Sync Doc" |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + ref: |
| 6 | + description: The base branch to publish a snapshot release from |
| 7 | + required: false |
| 8 | + default: "chore/no-issue-sync-doc-to-portal" |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - chore/no-issue-sync-doc-to-portal |
| 12 | + paths: |
| 13 | + - "apps/docs/pages/docs/*" |
| 14 | + |
| 15 | +jobs: |
| 16 | + sync_doc: |
| 17 | + runs-on: ubuntu-22.04 |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + ref: ${{ github.event.inputs.ref || github.event.ref }} |
| 22 | + path: ldmk |
| 23 | + sparse-checkout: | |
| 24 | + apps/docs/pages/docs |
| 25 | +
|
| 26 | + - uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + repository: ledgerhq/developer-portal |
| 29 | + path: portal |
| 30 | + token: ${{ secrets.DEVICE_SDK_TS_CI }} |
| 31 | + |
| 32 | + - name: Set up Git |
| 33 | + run: | |
| 34 | + git config --global user.name 'github-actions[bot]' |
| 35 | + git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' |
| 36 | +
|
| 37 | +
|
| 38 | + - name: Copy files |
| 39 | + run: | |
| 40 | + rm -rf portal/pages/docs/device-interaction |
| 41 | + mkdir -p portal/pages/docs/device-interaction |
| 42 | + cp -r ldmk/apps/docs/pages/docs/* portal/pages/docs/device-interaction |
| 43 | +
|
| 44 | +
|
| 45 | + - name: Set branch name in outputs |
| 46 | + id: branch-name |
| 47 | + run: | |
| 48 | + branch_name="sync-dmk-doc-$(date +%Y-%m-%d-%H-%M)" |
| 49 | + echo "BRANCH_NAME=$branch_name" >> $GITHUB_OUTPUT |
| 50 | +
|
| 51 | + - name: Commit changes |
| 52 | + run: | |
| 53 | + cd portal |
| 54 | + # add timestamp to commit message |
| 55 | + git checkout -b ${{ steps.branch-name.outputs.BRANCH_NAME }} |
| 56 | + git add pages/docs/device-interaction |
| 57 | + git commit -m "doc: add new changes from device management kit to portal" |
| 58 | +
|
| 59 | + - name: Create pull request |
| 60 | + env: |
| 61 | + GH_TOKEN: ${{ secrets.DEVICE_SDK_TS_CI }} |
| 62 | + run: | |
| 63 | + cd portal |
| 64 | + git push origin ${{ steps.branch-name.outputs.BRANCH_NAME }} |
| 65 | + gh pr create --title "doc: add new changes from device management kit to portal" --body "update doc from device management kit" --base main --head ${{ steps.branch-name.outputs.BRANCH_NAME }} |
0 commit comments