summaryrefslogtreecommitdiff
path: root/.github/workflows/push.yml
blob: e85b222a8385a8d47ef060cabfae10a094ceccb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
on:
  push:
    tags:
      - '*'

name: Deploy workflow

jobs:
  install:
    name: Install
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [12.x]

    steps:
      - uses: actions/checkout@v1

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}

      - name: Cache node modules
        uses: actions/cache@v1
        with:
          path: node_modules
          key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.OS }}-build-${{ env.cache-name }}-
            ${{ runner.OS }}-build-
            ${{ runner.OS }}-

      - name: Install Lint Build
        run: |
          yarn
          yarn lint
          yarn build

      - name: Push to gh-pages
        # push only when the branch is publish
        # if: github.event_name == 'push' && github.event.ref == 'refs/heads/publish'
        env:
          GITHUB_TOKEN: ${{ secrets.TOKEN }}
          PUBLISH_DIR: public
          BRANCH: gh-pages
        run: |
          cd $PUBLISH_DIR
          ls -l
          git init
          git config user.name "${GITHUB_ACTOR}"
          git config user.email "${GITHUB_ACTOR}@noreply.github.com"
          git add .
          git status
          git commit -m "Push to gh-pages"
          git push -f https://$GITHUB_ACTOR:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:$BRANCH