Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
fix: setup automatic deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
cecilia-sanare committed Oct 4, 2022
1 parent 225381d commit 1435bd1
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 12 deletions.
19 changes: 19 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -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"
57 changes: 45 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- main
push:
tags:
- v*
branches:
- main

Expand All @@ -32,8 +30,8 @@ jobs:
name: Install Packages
run: npm ci

verify:
name: Verify
lint:
name: Lint
runs-on: ubuntu-latest
needs: [install]
steps:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
branches:
- main
plugins:
- '@semantic-release/commit-analyzer'
- '@semantic-release/release-notes-generator'
- '@semantic-release/github'

0 comments on commit 1435bd1

Please sign in to comment.