diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1666b27e..3f259486 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,52 +1,49 @@ -# .github/workflows/deploy.yml - -name: GitHub Pages +name: Deploy to GitHub Pages on: - push: - branches: - - master - paths: - - '.github/workflows/deploy.yml' - - 'documents/**' pull_request: + branches: [master] + push: + branches: [master] + +permissions: + contents: write jobs: - deploy: - runs-on: ubuntu-22.04 - permissions: - contents: write - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - defaults: - run: - working-directory: / + test-deploy: + if: github.event_name != 'push' + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - - name: Setup Node - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 with: - node-version: '14' - - - name: Get yarn cache - id: yarn-cache - run: echo "YARN_CACHE_DIR=$(yarn cache dir)" >> "${GITHUB_OUTPUT}" - - - name: Cache dependencies - uses: actions/cache@v3 + fetch-depth: 0 + - uses: actions/setup-node@v4 with: - path: ${{ steps.yarn-cache.outputs.YARN_CACHE_DIR }} - key: ${{ runner.os }}-documents-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-documents- - - - run: yarn install --frozen-lockfile - - run: yarn build - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - if: github.ref == 'refs/heads/master' + node-version: 18 + cache: yarn + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Test build website + run: yarn build + deploy: + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./documents/build + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: yarn + - uses: webfactory/ssh-agent@v0.5.0 + with: + ssh-private-key: ${{ secrets.GH_PAGES_DEPLOY }} + - name: Deploy to GitHub Pages + env: + USE_SSH: true + run: | + git config --global user.email "actions@github.com" + git config --global user.name "gh-actions" + yarn install --frozen-lockfile + yarn deploy \ No newline at end of file diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml new file mode 100644 index 00000000..92cfd66f --- /dev/null +++ b/.github/workflows/test-deploy.yml @@ -0,0 +1,26 @@ +name: Test deployment + +on: + pull_request: + branches: + - master + # Review gh actions docs if you want to further define triggers, paths, etc + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on + +jobs: + test-deploy: + name: Test deployment + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: yarn + + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Test build documents + run: yarn build \ No newline at end of file