From 3cbc34c620275f85b4b77ac5c35b8eac229dd6e9 Mon Sep 17 00:00:00 2001 From: winwin2011 Date: Mon, 23 May 2022 20:11:05 +0800 Subject: [PATCH] chore: ci --- .github/workflows/release.yml | 56 +++++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 33 +++++++++++++++++++++ package.json | 1 + 3 files changed, 90 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..753bfb9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: CI + +on: + push: + branches: + - main + tags: + - 'v*' + pull_request: + branches: + - main + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + winwin2011/imageur + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set node + uses: actions/setup-node@v3 + with: + node-version: 16.x + + - run: npx conventional-github-releaser -p angular + env: + GITHUB_API_TOKEN: ${{secrets.PERSONAL_ACCESS_TOKEN}} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..8b1271e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,33 @@ +name: Test + +on: + push: + branches: + - main + + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x, 18.x] + + steps: + - uses: actions/checkout@v3 + - name: Install pnpm + uses: pnpm/action-setup@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - name: Install + run: pnpm install + - name: Lint + run: pnpm run lint + - name: Test + run: pnpm run test diff --git a/package.json b/package.json index ff4c206..a25040f 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "imageur", "version": "0.0.1", "private": true, + "packageManager": "pnpm@7.0.0", "description": "Image pool management site", "keywords": [ "image pool",