Skip to content

Commit 7e4ed56

Browse files
feat(deployment): Add Semantic Release for auto-release (#456)
* feat: release docker image to github container registry * fix: rename workflow * feat: semantic release github action * fix: rename github release workflow * fix: rebuilt package-lock * Update .github/workflows/github-release.yml Co-authored-by: Chris Ward <cdurianward@gmail.com> * fix: aggregate ci/cd into single workflow * fix: conditional logic for docker release Co-authored-by: brittonhayes <brittonhayes@users.noreply.github.com> Co-authored-by: Chris Ward <cdurianward@gmail.com>
1 parent f2896fe commit 7e4ed56

5 files changed

Lines changed: 5395 additions & 10861 deletions

File tree

.github/workflows/ci.yml

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
33

4-
name: 5e Database CI
4+
name: 5e Database CI/CD
55

66
on:
77
push:
88
branches: [main]
9+
tags:
10+
- 'v*'
911
pull_request:
1012
branches: [main]
1113

@@ -21,6 +23,7 @@ jobs:
2123
node-version: 14.x
2224
- run: npm install
2325
- run: npm run lint
26+
2427
test:
2528
name: Run tests
2629
runs-on: ubuntu-latest
@@ -32,11 +35,12 @@ jobs:
3235
node-version: 14.x
3336
- run: npm install
3437
- run: npm run test
38+
3539
deploy:
3640
name: Deploy
3741
runs-on: ubuntu-latest
3842
needs: [test, lint]
39-
if: github.ref == 'refs/heads/main'
43+
if: github.event_name != 'pull_request'
4044
steps:
4145
- uses: actions/checkout@v2
4246
- name: Use Node.js 14.x
@@ -49,6 +53,69 @@ jobs:
4953
run: |
5054
npm install
5155
npm run db:refresh
56+
57+
github-release:
58+
name: Github Release
59+
runs-on: ubuntu-latest
60+
needs: [test, lint, deploy]
61+
if: github.event_name != 'pull_request'
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v2
65+
with:
66+
fetch-depth: 0
67+
- name: Setup Node.js
68+
uses: actions/setup-node@v2
69+
with:
70+
node-version: 'lts/*'
71+
- name: Install dependencies
72+
run: npm install
73+
- name: Release
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
run: npx semantic-release
77+
78+
container-release:
79+
name: Container Release
80+
runs-on: ubuntu-latest
81+
needs: [test, lint, deploy, github-release]
82+
if: github.event_name != 'pull_request'
83+
env:
84+
REGISTRY: ghcr.io
85+
IMAGE_NAME: ${{ github.repository }}
86+
permissions:
87+
contents: read
88+
packages: write
89+
steps:
90+
- name: Checkout repository
91+
uses: actions/checkout@v2
92+
93+
- name: Log in to the Container registry
94+
uses: docker/login-action@v1
95+
with:
96+
registry: ${{ env.REGISTRY }}
97+
username: ${{ github.actor }}
98+
password: ${{ secrets.GITHUB_TOKEN }}
99+
100+
- name: Extract metadata (tags, labels) for Docker
101+
id: meta
102+
uses: docker/metadata-action@v3
103+
with:
104+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
105+
tags: |
106+
type=ref,event=branch
107+
type=ref,event=pr
108+
type=semver,pattern={{version}}
109+
type=semver,pattern={{major}}.{{minor}}
110+
111+
- name: Build and push Docker image
112+
uses: docker/build-push-action@v2
113+
with:
114+
context: .
115+
push: ${{ github.event_name != 'pull_request' }}
116+
tags: ${{ steps.meta.outputs.tags }}
117+
labels: ${{ steps.meta.outputs.labels }}
118+
52119
trigger_downstream:
53120
name: Trigger downstream
54121
runs-on: ubuntu-20.04

.github/workflows/release.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.releaserc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"plugins": [
3+
"@semantic-release/commit-analyzer",
4+
"@semantic-release/release-notes-generator",
5+
"@semantic-release/github"
6+
]
7+
}

0 commit comments

Comments
 (0)