name: Fandom Dev Wiki Updater

on:
  push:
    tags: ['*']

jobs:
  build:
    # 使用最新版ubantu虚拟机运行
    runs-on: ubuntu-latest

    steps:
      # from: https://github.com/actions/checkout
      - name: 本工作流
        uses: actions/checkout@master

      # 安装最新版 Node.js
      # from: https://github.com/actions/setup-node
      - name: 安装 Node.js
        uses: actions/setup-node@master
        with:
          node-version: 14
          registry-url: https://registry.npmjs.org/

      - name: 安装 yarn
        run: |
          npm install yarn -g
      - name: 安装项目依赖
        run: |
          yarn install
      - name: 构建项目
        run: |
          yarn build
      - name: 部署到 dev.fandom.com
        env:
          MW_USERNAME: ${{ secrets.MW_USERNAME }}
          MW_PASSWORD: ${{ secrets.MW_PASSWORD }}
        run: |
          node script/fandom-updater.js
