Skip to content

Commit

Permalink
chore: github CI
Browse files Browse the repository at this point in the history
Build, push, and if tags are present deploy.
  • Loading branch information
alextes committed May 30, 2022
1 parent 4c06eed commit 0f18c8a
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: build

on:
push:
tags:
- "stag-*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DigitalOcean Registry
uses: docker/login-action@v1
with:
registry: registry.digitalocean.com/ultrasoundmoney
username: ${{ secrets.DO_REGISTRY_USERNAME }}
password: ${{ secrets.DO_REGISTRY_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: registry.digitalocean.com/ultrasoundmoney/serve-web
tags: |
type=raw,latest
type=sha,prefix=
- name: Wait for tests to succeed
uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
check-name: test
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=registry.digitalocean.com/ultrasoundmoney/serve-web:latest
cache-to: type=inline
38 changes: 38 additions & 0 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: deploy-prod

on:
push:
tags:
- "prod-*"

jobs:
wait-on-build:
name: wait on build
runs-on: ubuntu-latest
steps:
- name: Wait for build to succeed
uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
check-name: build
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
deploy-serve-web:
name: deploy serve-web
runs-on: ubuntu-latest
needs: deploy-k8s-resources
steps:
- uses: actions/checkout@master
- name: Make short SHA available
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: deploy
uses: steebchen/[email protected]
with:
config: ${{ secrets.KUBE_CONFIG_DATA_PROD }}
command: set image deployment/serve-web serve-web=registry.digitalocean.com/ultrasoundmoney/gas-analysis:${{ steps.vars.outputs.sha_short }}
- name: Verify deployment
uses: steebchen/[email protected]
with:
config: ${{ secrets.KUBE_CONFIG_DATA_PROD }}
command: rollout status deployment/serve-web
38 changes: 38 additions & 0 deletions .github/workflows/deploy-stag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: deploy-staging

on:
push:
tags:
- "stag-*"

jobs:
wait-on-build:
name: wait on build
runs-on: ubuntu-latest
steps:
- name: Wait for build to succeed
uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
check-name: build
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
deploy-serve-web:
name: deploy serve-web
runs-on: ubuntu-latest
needs: deploy-k8s-resources
steps:
- uses: actions/checkout@master
- name: Make short SHA available
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: deploy
uses: steebchen/[email protected]
with:
config: ${{ secrets.KUBE_CONFIG_DATA_STAG }}
command: set image deployment/serve-web serve-web=registry.digitalocean.com/ultrasoundmoney/serve-web:${{ steps.vars.outputs.sha_short }}
- name: Verify deployment
uses: steebchen/[email protected]
with:
config: ${{ secrets.KUBE_CONFIG_DATA_STAG }}
command: rollout status deployment/serve-web
27 changes: 27 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: test

on:
push:
branches: [main]
tags:
- "stag-*"
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Node.js
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: install deps
run: yarn install
- name: check types
run: yarn check-types
- name: lint
run: yarn lint
- name: test
run: yarn build

0 comments on commit 0f18c8a

Please sign in to comment.