Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Migrate to TypeScript and provide Docker image
Browse files Browse the repository at this point in the history
Change-Id: If1666614676b92dd396d363a3068eac288f212ba
  • Loading branch information
achembarpu committed Jul 22, 2022
1 parent 1041811 commit b515b9b
Show file tree
Hide file tree
Showing 24 changed files with 11,854 additions and 968 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
build/
24 changes: 11 additions & 13 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"extends": ["eslint:recommended", "google"],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"env": {
"es6": true,
"node": true
},
"rules": {
"no-console": "off",
"require-jsdoc": "off"
}
"extends": "./node_modules/gts/",
"rules": {
"no-console": "off",
"require-jsdoc": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
}
]
}
}
16 changes: 5 additions & 11 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# git
.git

# nodejs
node_modules/
yarn.lock
#!include:.gitignore

# sensitive
*.json
!package.json
# git
.git/

# temp
.DS_Store
# GitHub
.github/
79 changes: 79 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# GitHub Release Workflow
# Triggers:
# 1. prereleased - a pre-release is created
# 2. edited - a release, pre-release, or draft release is edited
# Steps:
# 1. Build from source
# 2. Upload a zip artifact to the GitHub Release
# 3. Build & Publish a Docker Image to GitHub Container Registry

name: release

on:
release:
types: [prereleased, edited]

env:
BUILD_DIR: "./dist/"
PACK_BUILDER: gcr.io/buildpacks/builder:v1
FUNCTION_NAME: ${{ github.event.repository.name }}
FUNCTION_TYPE: http
REGISTRY: ghcr.io
IMAGE: ${{ github.repository }}
TAG: ${{ github.event.release.tag_name }}
ARTIFACT: "${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.zip"

jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
# actions/[email protected]
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579

- name: Choose NodeJS version
# actions/[email protected]
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561
with:
node-version: 16

- name: Install dependencies
run: npm ci

- name: Run build script
run: npm run build

- name: Zip & Upload to GitHub Release
working-directory: ${{ env.BUILD_DIR }}
run: |
zip -r "$ARTIFACT" ./
gh release upload "$TAG" "$ARTIFACT" --clobber
rm -f "$ARTIFACT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Buildpacks Pack
# buildpacks/github-actions/[email protected]
uses: buildpacks/github-actions/setup-pack@0b5cd009ad32942e90a3f9aef30c0a55cc9f4aed

- name: Log in to the Container registry
# docker/[email protected]
uses: docker/login-action@42d299face0c5c43a0487c477f595ac9cf22f1a7
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build & Publish Docker image to GHCR
working-directory: ${{ env.BUILD_DIR }}
shell: bash
run: |
#!/usr/bin/env bash
set -euo pipefail
pack build \
--path ./ \
--builder $PACK_BUILDER \
--env GOOGLE_FUNCTION_SIGNATURE_TYPE=$FUNCTION_TYPE \
--env GOOGLE_FUNCTION_TARGET=$FUNCTION_NAME \
--tag "$REGISTRY/$IMAGE:latest" \
--publish "$REGISTRY/$IMAGE:$TAG"
20 changes: 14 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# nodejs
node_modules/
yarn.lock

# sensitive
# Eg: Service Account keyfiles
*.json

# nodejs
node_modules/
!package.json
!package-lock.json
!tsconfig.json

# misc
*~
.DS_Store
.vscode/

# temp
.DS_Store
# artifacts
dist/
tsconfig.tsbuildinfo
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require('gts/.prettierrc.json')
}
Loading

0 comments on commit b515b9b

Please sign in to comment.