From 1435bd14b95e2510925e92ae7f3693e38f11b8f5 Mon Sep 17 00:00:00 2001 From: Ceci Date: Tue, 4 Oct 2022 18:34:40 -0500 Subject: [PATCH] fix: setup automatic deployments --- .env | 19 +++++++++++++ .github/workflows/main.yml | 57 ++++++++++++++++++++++++++++++-------- .releaserc.yml | 6 ++++ 3 files changed, 70 insertions(+), 12 deletions(-) create mode 100644 .env create mode 100644 .releaserc.yml diff --git a/.env b/.env new file mode 100644 index 0000000..7bb1443 --- /dev/null +++ b/.env @@ -0,0 +1,19 @@ +# Created by Vercel CLI +VERCEL="1" +VERCEL_ENV="development" +VERCEL_URL="" +VERCEL_GIT_PROVIDER="" +VERCEL_GIT_PREVIOUS_SHA="" +VERCEL_GIT_REPO_SLUG="" +VERCEL_GIT_REPO_OWNER="" +VERCEL_GIT_REPO_ID="" +VERCEL_GIT_COMMIT_REF="" +VERCEL_GIT_COMMIT_SHA="" +VERCEL_GIT_COMMIT_MESSAGE="" +VERCEL_GIT_COMMIT_AUTHOR_LOGIN="" +VERCEL_GIT_COMMIT_AUTHOR_NAME="" +NEXTAUTH_SECRET="3fNx9V9aGg+XF1/LoL4zCe6OqIWFTcLkcuxmqR44aLk=" +DISCORD_CLIENT_SECRET="JPXaGrVUY2x_UtYv68GvVvOPJmEv5kE8" +DISCORD_CLIENT_ID="1025079602567192658" +NEXTAUTH_URL="http://localhost:3000" +DATABASE_URL="postgresql://rain:f60e9ffd5b12fb6f583337b16c15155edb05b1e9fd18627c2e76ac54f63e01f0@157.230.85.134/silvy-alpha" \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b81246d..e965ca7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,8 +5,6 @@ on: branches: - main push: - tags: - - v* branches: - main @@ -32,8 +30,8 @@ jobs: name: Install Packages run: npm ci - verify: - name: Verify + lint: + name: Lint runs-on: ubuntu-latest needs: [install] steps: @@ -50,6 +48,23 @@ jobs: key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} - name: Linting run: npm run lint + + coverage: + name: Coverage + runs-on: ubuntu-latest + needs: [install] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v3 + with: + node-version: '16' + cache: 'npm' + - name: Cache Node Modules + id: cache-npm + uses: actions/cache@v3 + with: + path: node_modules/ + key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} - name: Coverage run: npm run test:coverage - name: Coveralls @@ -83,11 +98,29 @@ jobs: - name: Build run: npm run build + semantic: + name: Semantic Release + runs-on: ubuntu-latest + needs: [lint, coverage, build] + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + outputs: + published: ${{ steps.semantic.outputs.new_release_published }} + major: ${{ steps.semantic.outputs.new_release_major_version }} + minor: ${{ steps.semantic.outputs.new_release_minor_version }} + patch: ${{ steps.semantic.outputs.new_release_patch_version }} + steps: + - uses: actions/checkout@v2 + - name: Semantic Release + id: semantic + uses: cycjimmy/semantic-release-action@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + deploy-docker: name: Deploy (Docker Hub) runs-on: ubuntu-latest - needs: [verify, build] - if: startsWith(github.ref, 'refs/tags/v') + needs: semantic + if: needs.semantic.outputs.published == 'true' steps: - uses: actions/checkout@v2 - name: Cache Node Modules @@ -116,13 +149,13 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + uses: docker/metadata-action@v4 with: images: rainbowcafe/silvy tags: | - type=semver,pattern={{major}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{version}} + type=raw,value=${{ needs.semantic.outputs.major }} + type=raw,value=${{ needs.semantic.outputs.major }}.${{ needs.semantic.outputs.minor }} + type=raw,value=${{ needs.semantic.outputs.major }}.${{ needs.semantic.outputs.minor }}.${{ needs.semantic.outputs.patch }} - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc @@ -145,8 +178,8 @@ jobs: deploy-live: name: Deploy (Vercel) runs-on: ubuntu-latest - needs: [verify, build] - if: startsWith(github.ref, 'refs/tags/v') + needs: semantic + if: needs.semantic.outputs.new_release_published == 'true' steps: - uses: actions/checkout@v2 - name: Cache Node Modules diff --git a/.releaserc.yml b/.releaserc.yml new file mode 100644 index 0000000..b106a5d --- /dev/null +++ b/.releaserc.yml @@ -0,0 +1,6 @@ +branches: + - main +plugins: + - '@semantic-release/commit-analyzer' + - '@semantic-release/release-notes-generator' + - '@semantic-release/github' \ No newline at end of file