-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
changelog: | ||
exclude: | ||
labels: | ||
- exclude from release notes | ||
categories: | ||
- title: Maintenance | ||
labels: | ||
- maintenance | ||
- title: New Features | ||
labels: | ||
- new feature | ||
- title: Improvements | ||
labels: | ||
- improvement | ||
- title: Bug Fixes | ||
labels: | ||
- bug | ||
- title: Other | ||
labels: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
latest: | ||
description: | ||
Release as the latest version, tagging the images with the version number found in | ||
package.json. | ||
default: false | ||
type: boolean | ||
|
||
jobs: | ||
tags: | ||
name: Compose version tags | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Parse semver number from package.json | ||
run: | | ||
PACKAGE_VERSION=$(cat package.json | jq '.version' | tr -d '"') | ||
echo "MAJOR=$(echo $PACKAGE_VERSION | cut -d "." -f 1)" >> $GITHUB_ENV | ||
echo "MINOR=$(echo $PACKAGE_VERSION | cut -d "." -f 2)" >> $GITHUB_ENV | ||
echo "PATCH=$(echo $PACKAGE_VERSION | cut -d "." -f 3)" >> $GITHUB_ENV | ||
- name: Compose Docker tags | ||
run: | | ||
echo "MAJOR_V=ghcr.io/funidata/kaiku:$MAJOR" >> $GITHUB_ENV | ||
echo "MINOR_V=ghcr.io/funidata/kaiku:$MAJOR.$MINOR" >> $GITHUB_ENV | ||
echo "FULL_V=ghcr.io/funidata/kaiku:$MAJOR.$MINOR.$PATCH" >> $GITHUB_ENV | ||
- name: Compose tag list | ||
run: echo "TAG_LIST=$MAJOR_V,$MINOR_V,$FULL_V,ghcr.io/funidata/kaiku:latest" >> $GITHUB_ENV | ||
- name: Select correct tags | ||
id: tags | ||
run: | ||
echo SELECTED_TAGS=$(if [ ${{ inputs.latest }} = true ]; then echo $TAG_LIST; else echo | ||
"ghcr.io/funidata/kaiku:next"; fi) >> $GITHUB_OUTPUT | ||
outputs: | ||
tag-list: ${{ steps.tags.outputs.SELECTED_TAGS }} | ||
|
||
publish: | ||
name: Publish image | ||
needs: | ||
- tags | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build production image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: app | ||
push: true | ||
tags: ${{ needs.tags.outputs.tag-list }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Release new version | ||
|
||
on: | ||
release: | ||
types: | ||
- released | ||
|
||
jobs: | ||
tests: | ||
name: Run tests | ||
uses: ./.github/workflows/run-tests.yaml | ||
|
||
release: | ||
name: Publish image (latest) | ||
uses: ./.github/workflows/publish-image.yaml | ||
with: | ||
latest: true | ||
needs: | ||
- tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Production image. | ||
FROM node:20.17 AS build | ||
|
||
ENV NODE_ENV=production | ||
|
||
# Build backend. | ||
WORKDIR /usr/src/app | ||
COPY package.json package-lock.json ./ | ||
RUN npm ci --include dev | ||
COPY . . | ||
RUN npm run build | ||
RUN npm prune | ||
|
||
# Final build stage to pick only actually needed files into the image. | ||
FROM node:20.17-alpine | ||
|
||
LABEL org.opencontainers.image.description="Kaiku backend image." | ||
|
||
USER node | ||
|
||
WORKDIR /app | ||
COPY --from=build /usr/src/app/dist ./dist | ||
COPY --from=build /usr/src/app/node_modules ./node_modules | ||
|
||
# Run database migrations before booting server. | ||
CMD ["node", "dist/main.js"] |