Skip to content

Commit

Permalink
add workflow
Browse files Browse the repository at this point in the history
Signed-off-by: cbh778899 <[email protected]>
  • Loading branch information
cbh778899 committed Jul 29, 2024
1 parent 3ab693a commit a280ab1
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.devcontainer
.git
.github
.vscode
.gitignore
Dockerfile
README.md
node_modules
package-lock.json
pnpm-lock.yaml
eslint.config.mjs
LICENSE
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: monthly
32 changes: 32 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'enhancement'
- 'feature'
- title: '🐛 Bug Fixes'
labels:
- 'bugfix'
- title: '🧰 Maintenance'
label: 'CI'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## What's New
$CHANGES
## Contributors
Thank you to our contributors for making this release possible:
$CONTRIBUTORS
56 changes: 56 additions & 0 deletions .github/workflows/linter-builder-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 'Linter and Builder checker 🚀'
on:
pull_request:
branches:
- 'main'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true

jobs:
code_quality:
name: 'Code Quality📦'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm install
- name: Run ESLint
run: npm run lint

builder:
name: 'Build Docker Image🔨'
runs-on: ubuntu-latest
needs: [code_quality]
strategy:
matrix:
config:
- { dockerfile: "Dockerfile", platforms: "linux/amd64,linux/arm64" }

steps:

- name: Check repo
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Get Commit Hash
id: commit
shell: bash
run: |
echo "SHORT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: Build Docker image
if: startsWith(github.ref, 'refs/tags/') != true && success()
uses: docker/build-push-action@v4
with:
context: .
push: false
platforms: ${{ matrix.config.platforms }}
tags: "ghcr.io/${{ secrets.NAMESPACE }}/${{ secrets.IMAGE_NAME }}:${{ env.SHORT_HASH }}"
file: ${{ matrix.config.dockerfile }}
38 changes: 38 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 'Release Drafter 🚀'

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- main
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
# pull_request_target event is required for autolabeler to support PRs from forks
# pull_request_target:
# types: [opened, reopened, synchronize]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v6
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
with:
config-name: release-drafter.yml
# https://github.com/release-drafter/release-drafter/issues/1125
commitish: main
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 changes: 51 additions & 0 deletions .github/workflows/release-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Releasing Image 🚀'
on:
push:
tags:
- 'v*'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true

jobs:
release_image:
name: 'Releasing Image 🐳'
strategy:
matrix:
config:
- { dockerfile: "Dockerfile", platforms: "linux/amd64,linux/arm64" }
runs-on: ubuntu-latest
steps:
- name: Check repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Github Container Registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') && success()
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get Tag Name
id: tag
shell: bash
run: |
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Push Docker image
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') && success()
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: ${{ matrix.config.platforms }}
tags: "ghcr.io/${{ secrets.NAMESPACE }}/${{ secrets.IMAGE_NAME }}:${{ env.TAG }}"
file: ${{ matrix.config.dockerfile }}
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:20.15.1-slim
WORKDIR /app
COPY . .

HEALTHCHECK --interval=300s --timeout=30s --start-period=5s --retries=3 CMD [ "node", "healthy-check.js" ]
RUN npm install -g pnpm && pnpm install
EXPOSE 8000
ENTRYPOINT [ "npm", "start" ]
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PROJECT_NAME:=voyager
CONTAINER_NAME:=voyager:v0.1.0
PORT:=8000


.PHONY: build
build:
@docker build -t $(CONTAINER_NAME) .

.PHONY: run
run: build
@docker run --rm -p $(PORT):$(PORT) --name $(PROJECT_NAME) $(CONTAINER_NAME)

0 comments on commit a280ab1

Please sign in to comment.