xref: /expo/.github/workflows/docs.yml (revision ef147105)
1name: docs
2
3defaults:
4  run:
5    shell: bash
6    working-directory: docs
7
8on:
9  workflow_dispatch: {}
10  push:
11    branches: [master]
12    paths:
13      - 'docs/**'
14      - '.github/workflows/docs.yml'
15  pull_request:
16    branches: [master]
17    paths:
18      - 'docs/**'
19      - '.github/workflows/docs.yml'
20
21jobs:
22  docs:
23    runs-on: ubuntu-18.04
24    steps:
25      - name: Check out repository
26        uses: actions/checkout@v2
27        with:
28          submodules: true
29      - name: Get yarn cache directory path
30        id: yarn-cache-dir-path
31        run: echo "::set-output name=dir::$(yarn cache dir)"
32      - uses: actions/cache@v2
33        with:
34          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
35          key: ${{ runner.os }}-yarn-${{ hashFiles('docs/yarn.lock') }}
36          restore-keys: |
37            ${{ runner.os }}-yarn-
38      - run: yarn install --frozen-lockfile
39      - run: yarn test
40      - run: yarn danger ci
41        env:
42          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43      - name: Cache Next folder
44        uses: actions/cache@v2
45        with:
46          path: docs/.next
47          key: docs-next-${{ hashFiles('docs/yarn.lock') }}-${{ hashFiles('docs/pages/**') }}
48          restore-keys: |
49            docs-next-${{ hashFiles('docs/yarn.lock') }}-
50            docs-next-
51      - name: Cache Babel MDX folder
52        uses: actions/cache@v2
53        with:
54          path: docs/node_modules/.cache/babel-mdx-loader
55          key: docs-babel-mdx-${{ hashFiles('docs/yarn.lock') }}
56          restore-keys: |
57            docs-babel-mdx-${{ hashFiles('docs/yarn.lock') }}
58            docs-babel-mdx-
59      - run: yarn export
60        timeout-minutes: 15
61      - name: test links
62        run: |
63          yarn export-server &
64          while ! nc -z localhost 8000; do
65            sleep 1
66          done
67          yarn test-links http://127.0.0.1:8000
68        timeout-minutes: 1
69      - run: ./deploy.sh
70        if: ${{ github.event.ref == 'refs/heads/master' }}
71        env:
72          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
73          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
74      - uses: 8398a7/action-slack@v3
75        if: failure() && github.event.ref == 'refs/heads/master'
76        env:
77          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78          SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_docs }}
79        with:
80          channel: '#docs'
81          status: ${{ job.status }}
82          fields: author,job,message
83          author_name: docs build
84