diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 234bc52..05e2cd7 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -1,11 +1,7 @@ name: Publish Docs on: - push: - branches: ['main'] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + workflow_call: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..9503dfe --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,14 @@ +name: Verify and Preview + +on: + pull_request: + branches: + - main + +permissions: + pull-requests: read + +jobs: + verify: + uses: ./.github/workflows/verify.yml + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a37ccd1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Release + +on: + workflow_call: + secrets: + TRENDYOL_JS_NPM_TOKEN: + required: true + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set Node env + uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Install dependencies + run: npm ci + - name: Run build + run: npm run build + - name: Create build artifact + uses: actions/upload-artifact@master + with: + name: build-output + path: lib/ + - name: Publish + run: npx semantic-release + env: + TRENDYOL_JS_NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/verify-and-release.yml b/.github/workflows/verify-and-release.yml new file mode 100644 index 0000000..9494228 --- /dev/null +++ b/.github/workflows/verify-and-release.yml @@ -0,0 +1,19 @@ +name: 'Verify and Release' + +on: + push: + branches: + - main + +jobs: + verify: + uses: ./.github/workflows/verify.yml + secrets: inherit + publish: + uses: ./.github/workflows/publish-docs.yml + needs: verify + secrets: inherit + release: + uses: ./.github/workflows/release.yml + needs: verify + secrets: inherit diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..156b0e4 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,27 @@ +name: Verify + +on: + workflow_call: + +jobs: + verify: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + - name: Set Node env + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Run linter check + run: npm run lint + - name: Run tests + run: npm run test + - name: Create coverage artifact + uses: actions/upload-artifact@master + with: + name: coverage-output + path: coverage/