|
| 1 | +name: Publish documentation on GitHub Pages |
| 2 | + |
| 3 | +on: workflow_dispatch |
| 4 | + |
| 5 | +jobs: |
| 6 | + authorize: |
| 7 | + name: Authorize |
| 8 | + runs-on: ubuntu-18.04 |
| 9 | + steps: |
| 10 | + - name: ${{ github.actor }} permission check to do a release |
| 11 | + uses: octokit/request-action@v2.0.0 |
| 12 | + with: |
| 13 | + route: GET /repos/:repository/collaborators/${{ github.actor }} |
| 14 | + repository: ${{ github.repository }} |
| 15 | + env: |
| 16 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 17 | + |
| 18 | + gh-pages: |
| 19 | + name: Publish to GitHub Pages |
| 20 | + runs-on: ubuntu-18.04 |
| 21 | + needs: [authorize] |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v1 |
| 26 | + |
| 27 | + - name: node_modules cache |
| 28 | + uses: actions/cache@v2 |
| 29 | + with: |
| 30 | + path: '**/node_modules' |
| 31 | + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} |
| 32 | + |
| 33 | + - name: Setup Node.js |
| 34 | + uses: actions/setup-node@v1 |
| 35 | + with: |
| 36 | + node-version: 10.x |
| 37 | + |
| 38 | + - name: Install dependencies |
| 39 | + run: yarn install --frozen-lockfile && yarn docs:install --frozen-lockfile |
| 40 | + |
| 41 | + - name: Generate website assets |
| 42 | + run: yarn docs:generate-jsdoc |
| 43 | + |
| 44 | + - name: Add key to allow access to repository |
| 45 | + env: |
| 46 | + SSH_AUTH_SOCK: /tmp/ssh_agent.sock |
| 47 | + run: | |
| 48 | + mkdir -p ~/.ssh |
| 49 | + ssh-keyscan github.com >> ~/.ssh/known_hosts |
| 50 | + echo "${{ secrets.GH_PAGES_DEPLOY }}" > ~/.ssh/id_rsa |
| 51 | + chmod 600 ~/.ssh/id_rsa |
| 52 | + cat <<EOT >> ~/.ssh/config |
| 53 | + Host github.com |
| 54 | + HostName github.com |
| 55 | + IdentityFile ~/.ssh/id_rsa |
| 56 | + EOT |
| 57 | +
|
| 58 | + - name: Release to GitHub Pages |
| 59 | + env: |
| 60 | + USE_SSH: true |
| 61 | + GIT_USER: amplitude-sdk-bot |
| 62 | + run: | |
| 63 | + git config --global user.email "amplitude-sdk-bot@users.noreply.github.com" |
| 64 | + git config --global user.name "amplitude-sdk-bot" |
| 65 | + yarn docs:deploy |
0 commit comments