Skip to content

Commit

Permalink
Added/updated cicd supporting artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
petruki committed Oct 8, 2023
1 parent 8262ff9 commit a655b8a
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 1 deletion.
65 changes: 64 additions & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,67 @@ jobs:
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

docker:
name: Publish Docker Image
needs: [ build-test ]
runs-on: ubuntu-latest
if: success() && github.ref == 'refs/heads/master'

outputs:
digest: ${{ steps.docker_build.outputs.digest }}

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

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

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
push: true
platforms: linux/amd64
tags: trackerforce/switcher-searchdocs:latest

update-kustomize:
name: Deploy
needs: [ docker ]
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: 'master'

- name: Checkout Kustomize
uses: actions/checkout@v3
with:
token: ${{ secrets.ARGOCD_PAT }}
repository: switcherapi/switcher-deployment
ref: master

- name: Set Image
uses: stefanprodan/kube-tools@v1
with:
kubectl: 1.24.0
kustomize: 4.5.4
command: |
cd switcher-searchdocs/base
echo RELEASE_TIME=`date` > environment-properties.env
kustomize edit set image trackerforce/switcher-searchdocs:latest=trackerforce/switcher-searchdocs@${{ needs.docker.outputs.digest }}
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
git add .
git commit -m "[argocd] switcher-searchdocs: ${{ needs.docker.outputs.digest }}"
git push
67 changes: 67 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release CI

on:
release:
types: [ created ]

jobs:
build-test:
name: Build & Test
runs-on: ubuntu-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"

steps:
- name: Git checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Deno v1.36.1
uses: denoland/setup-deno@v1
with:
deno-version: v1.36.1

- name: Verify formatting
run: deno task fmt

- name: Run linter
run: deno lint

- name: Run tests and coverage
run: deno task test

docker:
name: Publish Docker Image
needs: [ build-test ]
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: trackerforce/switcher-searchdocs

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

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

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM denoland/deno:alpine-1.37.0

ENV APP_HOME=/home/app
WORKDIR $APP_HOME

COPY /src/deps.ts $APP_HOME

RUN deno cache deps.ts

COPY /src .

RUN addgroup -S app && \
adduser -S app -G app && \
chown -R app:app $APP_HOME /deno-dir

USER app
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ A remote document search engine that uses Skimming for Deno<br><br>

[![Master CI](https://github.com/switcherapi/switcher-searchdocs/actions/workflows/master.yml/badge.svg)](https://github.com/switcherapi/switcher-searchdocs/actions/workflows/master.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=switcherapi_switcher-searchdocs&metric=alert_status)](https://sonarcloud.io/dashboard?id=switcherapi_switcher-searchdocs)
[![Docker Hub](https://img.shields.io/docker/pulls/trackerforce/switcher-searchdocs.svg)](https://hub.docker.com/r/trackerforce/switcher-searchdocs)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Slack: Switcher-HQ](https://img.shields.io/badge/slack-@switcher/hq-blue.svg?logo=slack)](https://switcher-hq.slack.com/)

Expand Down
37 changes: 37 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: '3.8'

# TLS Enabled
# volumes:
# switcherapi-tls:
# driver: local
# driver_opts:
# o: bind
# type: none
# device: "/data/certs"

services:
app:
image: trackerforce/switcher-searchdocs:latest
container_name: switcher-searchdocs
command: ["run", "--allow-net", "--allow-env", "--allow-read", "index.ts"]
ports:
- 4000:4000
environment:
- APP_PORT=4000
- RELEASE_TIME=today
# - SSL_CERT=/etc/ssl/certs/tls.crt
# - SSL_KEY=/etc/ssl/certs/tls.pem

- APP_RATE_LIMIT=10
- APP_RATE_LIMIT_WINDOW=3000
- LOG_LEVEL=INFO # DEBUG, INFO, ERROR

# Skimming Global Settings
- APP_URL=https://raw.githubusercontent.com/petruki/skimming/master/
- APP_FILES=README.md
- APP_CACHE_EXP_DURATION=5
- APP_CACHE_SIZE=100
- APP_ALLOW_URL=false
- APP_ALLOW_FILES=false
# volumes:
# - switcherapi-tls:/etc/ssl/certs

0 comments on commit a655b8a

Please sign in to comment.