Skip to content

Commit

Permalink
feat: initialize repository
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenShibata committed Mar 19, 2023
0 parents commit 34ec043
Show file tree
Hide file tree
Showing 7 changed files with 872 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Enforce UNIX newlines (LF)
* text=auto eol=lf
4 changes: 4 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>frutbits/renovate-config"]
}
83 changes: 83 additions & 0 deletions .github/workflows/self-hosted-build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build & Push Docker Image to container image registry

on:
workflow_call:
inputs:
ADD_FLAVOR:
description: "Whether to add flavor (only -dev atm) to the image tag"
type: boolean
required: false
default: true
NO_CACHE:
description: "Whether to use build cache"
type: boolean
required: false
default: false
secrets:
BOT_TOKEN:
required: true

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
build:
runs-on: self-hosted
steps:
- name: Check Out Repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 2

#- name: Set up QEMU (We don't need QEMU, because we don't build images for platforms other than linux/amd64, which is our current native arch in our infra
# uses: docker/setup-qemu-action@v1.2.0

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@f03ac48505955848960e80bbb68046aa35c7b9e7 # v2.4.1

- name: Login to GitHub Container Registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
if: ${{ github.event_name != 'pull_request' }}
with:
registry: ghcr.io
username: frutbitsorg-bot
password: ${{ secrets.BOT_TOKEN }}

- name: Extract tag name
id: tags
if: ${{ github.event_name == 'release' }}
run: echo ::set-output name=name::${GITHUB_REF##*/}

- name: Extract flavor
id: flavor
if: ${{ inputs.ADD_FLAVOR == true }}
run: if [ "${{ github.event_name }}" = "release" ]; then echo ::set-output name=name::; else echo ::set-output name=name::-dev; fi

- name: Generate Docker image metadata
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
id: img_meta
with:
flavor: |
latest=auto
suffix=${{ steps.flavor.outputs.name }}
images: ghcr.io/${{ github.repository }}
tags: |
${{ steps.tags.outputs.name }}
latest
- name: Build and push
id: docker_build
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
with:
context: ./
tags: ${{ steps.img_meta.outputs.tags }}
labels: ${{ steps.img_meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
secrets: |
"GH_PKG_AUTH_TOKEN=${{ secrets.BOT_TOKEN }}"
"GITHUB_TOKEN=${{ secrets.BOT_TOKEN }}"
cache-from: type=gha,mode=max
cache-to: type=gha,mode=max
no-cache: ${{ inputs.NO_CACHE == true }}
65 changes: 65 additions & 0 deletions .github/workflows/self-hosted-lint-and-compile-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Lint code & compile test


on:
workflow_call:

jobs:
lint:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 2

- name: Setup pnpm
uses: pnpm/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd # v2.2.4
with:
version: latest

- name: Setup Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version-file: .node-version
check-latest: true
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run compose script if exists
run: pnpm run --if-present compose

- name: Lint code
run: pnpm run lint

compile:
needs: lint
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 2

- name: Setup pnpm
uses: pnpm/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd # v2.2.4
with:
version: latest

- name: Setup Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version-file: .node-version
check-latest: true
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run compose script if exists
run: pnpm run --if-present compose

- name: Test compile
run: pnpm run compile && rm -rf dist
40 changes: 40 additions & 0 deletions .github/workflows/self-hosted-publish-gh-registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish package to GitHub Packages registry

on:
workflow_call:

jobs:
publish:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 2

- name: Setup pnpm
uses: pnpm/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd # v2.2.4
with:
version: latest

- name: Setup Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version-file: .node-version
check-latest: true
cache: 'pnpm'
registry-url: https://npm.pkg.github.com/

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run compose script if exists
run: pnpm run --if-present compose

- name: Compile/Build TypeScript project
run: pnpm run build

- name: Publish package to npm and GitHub packages registry
run: pnpm run release
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.eol": "\n",
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": [".github/workflows/*.{yml,yaml}"]
}
}
Loading

0 comments on commit 34ec043

Please sign in to comment.