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 Feb 23, 2024
1 parent a3b456a commit 97a332b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 12 deletions.
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 97a332b

Please sign in to comment.