|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - beta |
| 8 | + pull_request: |
| 9 | + types: [opened, synchronize, reopened] |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.ref }}-${{ github.head_ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +env: |
| 16 | + NODE_VERSION: 16 |
| 17 | + |
| 18 | +jobs: |
| 19 | + install-cache: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout Commit |
| 23 | + uses: actions/checkout@v2 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + - name: Use Node.js |
| 27 | + uses: actions/setup-node@v1 |
| 28 | + with: |
| 29 | + node-version: ${{ env.NODE_VERSION }} |
| 30 | + - name: Cache dependencies |
| 31 | + uses: actions/cache@v2 |
| 32 | + id: cache-dependencies |
| 33 | + with: |
| 34 | + path: node_modules |
| 35 | + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} |
| 36 | + restore-keys: | |
| 37 | + ${{ runner.os }}-npm- |
| 38 | + - name: Install Dependencies |
| 39 | + if: steps.cache-dependencies.outputs.cache-hit != 'true' |
| 40 | + run: | |
| 41 | + npm ci |
| 42 | + static-analysis: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + needs: install-cache |
| 45 | + steps: |
| 46 | + - name: Checkout Commit |
| 47 | + uses: actions/checkout@v2 |
| 48 | + with: |
| 49 | + fetch-depth: 0 |
| 50 | + - name: Use Node.js |
| 51 | + uses: actions/setup-node@v1 |
| 52 | + with: |
| 53 | + node-version: ${{ env.NODE_VERSION }} |
| 54 | + - name: Restore dependencies |
| 55 | + uses: actions/cache@v2 |
| 56 | + id: cache-dependencies |
| 57 | + with: |
| 58 | + path: node_modules |
| 59 | + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} |
| 60 | + restore-keys: | |
| 61 | + ${{ runner.os }}-npm- |
| 62 | + - name: Run prettier |
| 63 | + run: | |
| 64 | + npm run format:check |
| 65 | + build: |
| 66 | + runs-on: ubuntu-latest |
| 67 | + needs: install-cache |
| 68 | + steps: |
| 69 | + - name: Checkout Commit |
| 70 | + uses: actions/checkout@v2 |
| 71 | + with: |
| 72 | + fetch-depth: 0 |
| 73 | + - name: Use Node.js |
| 74 | + uses: actions/setup-node@v1 |
| 75 | + with: |
| 76 | + node-version: ${{ env.NODE_VERSION }} |
| 77 | + - name: Restore dependencies |
| 78 | + uses: actions/cache@v2 |
| 79 | + id: cache-dependencies |
| 80 | + with: |
| 81 | + path: node_modules |
| 82 | + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} |
| 83 | + restore-keys: | |
| 84 | + ${{ runner.os }}-npm- |
| 85 | + - name: Cache gatsby dependencies |
| 86 | + uses: actions/cache@v2 |
| 87 | + with: |
| 88 | + path: | |
| 89 | + example/.cache |
| 90 | + example/public |
| 91 | + key: ${{ runner.os }}-gatsby-${{ hashFiles('**/package-lock.json', '**/gatsby-node.js', '**/gatsby-config.js') }} |
| 92 | + - name: Run build |
| 93 | + run: | |
| 94 | + npm run build |
| 95 | + - name: Upload build artifacts |
| 96 | + uses: actions/upload-artifact@v2 |
| 97 | + with: |
| 98 | + name: build-output |
| 99 | + path: example/public |
| 100 | + retention-days: 1 |
| 101 | + release: |
| 102 | + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta' |
| 103 | + runs-on: ubuntu-latest |
| 104 | + needs: [static-analysis, build] |
| 105 | + steps: |
| 106 | + - name: Checkout Commit |
| 107 | + uses: actions/checkout@v2 |
| 108 | + with: |
| 109 | + token: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} |
| 110 | + - name: Use Node.js |
| 111 | + uses: actions/setup-node@v1 |
| 112 | + with: |
| 113 | + node-version: ${{ env.NODE_VERSION }} |
| 114 | + - name: Restore dependencies |
| 115 | + uses: actions/cache@v2 |
| 116 | + id: cache-dependencies |
| 117 | + with: |
| 118 | + path: node_modules |
| 119 | + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} |
| 120 | + restore-keys: | |
| 121 | + ${{ runner.os }}-npm- |
| 122 | + - name: Restore gatsby dependencies |
| 123 | + uses: actions/cache@v2 |
| 124 | + with: |
| 125 | + path: | |
| 126 | + example/.cache |
| 127 | + example/public |
| 128 | + key: ${{ runner.os }}-gatsby-${{ hashFiles('**/package-lock.json', '**/gatsby-node.js', '**/gatsby-config.js') }} |
| 129 | + - name: Release |
| 130 | + env: |
| 131 | + GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} |
| 132 | + GIT_AUTHOR_NAME: commitd-bot |
| 133 | + GIT_AUTHOR_EMAIL: [email protected] |
| 134 | + GIT_COMMITTER_NAME: commitd-bot |
| 135 | + GIT_COMMITTER_EMAIL: [email protected] |
| 136 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 137 | + run: npx semantic-release |
| 138 | + working-directory: ./theme |
| 139 | + publish-docs: |
| 140 | + runs-on: ubuntu-latest |
| 141 | + needs: release |
| 142 | + steps: |
| 143 | + - name: Checkout Commit |
| 144 | + uses: actions/checkout@v2 |
| 145 | + with: |
| 146 | + token: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} |
| 147 | + fetch-depth: 0 |
| 148 | + - name: Use Node.js |
| 149 | + uses: actions/setup-node@v1 |
| 150 | + with: |
| 151 | + node-version: ${{ env.NODE_VERSION }} |
| 152 | + - name: Download build artifacts |
| 153 | + uses: actions/download-artifact@v2 |
| 154 | + with: |
| 155 | + name: build-output |
| 156 | + path: example/public |
| 157 | + - name: Publish Docs |
| 158 | + if: github.ref == 'refs/heads/main' |
| 159 | + run: npm run deploy:ci -w example |
| 160 | + env: |
| 161 | + GH_TOKEN: commitd-bot:${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} |
0 commit comments