ci: first attempt at general bits and bobs...

Obviously given the state of github yaml-engineering there's
no way I'm going to get this right on the first try
but hey ho. things *should* work.
This commit is contained in:
zkldi
2024-04-04 15:52:54 +01:00
parent 1200f00f92
commit bba153e656
5 changed files with 247 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
name: Bot CI/CD
on:
push:
branches:
- "main"
paths:
- "bot/**"
- "common/**"
workflow_dispatch:
jobs:
docker-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker Hub login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: ./
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/tachi-bot:stable
file: ./Dockerfile.bot
cache-from: type=gha,scope=$GITHUB_REF_NAME-bot
cache-to: type=gha,mode=max,scope=$GITHUB_REF_NAME-bot
+38
View File
@@ -0,0 +1,38 @@
name: Common CI/CD
on:
push:
branches:
- "main"
paths:
- "common/**"
pull_request:
branches:
- "main"
paths:
- "common/**"
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
with:
version: 7.20.0
- uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm
- name: Install dependencies
run: pnpm --filter tachi-common... --filter . install
- name: Run Tests
run: pnpm --filter tachi-common test
env:
NODE_ENV: "test"
+40
View File
@@ -0,0 +1,40 @@
name: Database-Seeds CI/CD
on:
push:
branches:
- "main"
paths:
- "database-seeds/**"
- "common/**"
pull_request:
branches:
- "main"
paths:
- "database-seeds/**"
- "common/**"
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
with:
version: 7.20.0
- uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm
- name: Install dependencies
run: pnpm --filter tachi-database-seeds-scripts... --filter . install
- name: Run Tests
run: pnpm --filter tachi-database-seeds-scripts test
env:
NODE_ENV: "test"
+39
View File
@@ -0,0 +1,39 @@
name: GitHub Bot CI/CD
on:
push:
branches:
- "main"
paths:
- "github-bot/**"
workflow_dispatch:
jobs:
docker-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker Hub login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: ./
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/tachi-gh-bot:stable
file: ./Dockerfile.ghbot
cache-from: type=gha,scope=$GITHUB_REF_NAME-github-bot
cache-to: type=gha,mode=max,scope=$GITHUB_REF_NAME-github-bot
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
+93
View File
@@ -0,0 +1,93 @@
name: Server CI/CD
on:
push:
branches:
- "main"
paths:
- "server/**"
- "common/**"
pull_request:
branches:
- "main"
paths:
- "server/**"
- "common/**"
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
env:
NODE_ENV: "test"
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7.20.0
- uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm
- name: Install dependencies
run: pnpm --filter tachi-server... --filter . install
- name: Lint code
run: pnpm --filter tachi-server lint
- name: Typecheck code
run: pnpm --filter tachi-server typecheck
# configure external dbs
- uses: supercharge/mongodb-github-action@1.4.1
- uses: supercharge/redis-github-action@1.1.0
- name: Run tests
run: pnpm --filter tachi-server test
env:
NODE_ENV: "test"
PORT: 8080
MONGO_URL: "127.0.0.1"
REDIS_URL: "127.0.0.1"
docker-push:
runs-on: ubuntu-latest
needs: [test]
defaults:
run:
working-directory: ./server
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker Hub login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Commit Hash
run: 'echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: ./
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/tachi-server:${{ env.BRANCH_TAG }}
file: ./Dockerfile.server
build-args: |
COMMIT_HASH=${{ env.SHORT_SHA }}
cache-from: type=gha,scope=$GITHUB_REF_NAME-server
cache-to: type=gha,mode=max,scope=$GITHUB_REF_NAME-server
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}