-
-
Notifications
You must be signed in to change notification settings - Fork 32
92 lines (87 loc) · 3.26 KB
/
snipsnap-templates-frontend.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: snipsnap-templates-frontend
on:
push:
branches: [master]
paths:
- templates/frontend/**
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
env:
WORKING_DIRECTORY: ./templates/frontend/
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14"
- name: Restore cache
uses: actions/cache@v2
with:
path: "./templates/frontend/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('./templates/frontend/package-lock.json') }}
- name: NPM Install
run: npm install
working-directory: ${{env.WORKING_DIRECTORY}}
- name: ESLint and stylelint
run: npm run lint
working-directory: ${{env.WORKING_DIRECTORY}}
build:
runs-on: ubuntu-latest
needs: lint
env:
WORKING_DIRECTORY: ./templates/frontend/
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14"
- name: NPM Install
run: npm ci
working-directory: ${{env.WORKING_DIRECTORY}}
- name: Build frontend
env:
SENTRY_ENABLED: true
SENTRY_ENVIRONMENT: production
SENTRY_URL: https://sentry.io/
SENTRY_ORG: ${{ secrets.SENTRY_ORG}}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT}}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN}}
NEXT_PUBLIC_SENTRY_DSN: ${{ secrets.NEXT_PUBLIC_SENTRY_DSN}}
NEXT_PUBLIC_SITE_URL: https://templates.snipsnap.dev
NEXT_PUBLIC_GRAPHQL_URL: https://hasura-t.snipsnap.dev/v1/graphql
run: npm run build
working-directory: ${{env.WORKING_DIRECTORY}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Pixel Point Container Registry
uses: docker/login-action@v1
with:
registry: https://registry.pixelpoint.io
username: ${{ secrets.DOCKER_USERNAME}}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./templates/frontend
file: ./templates/frontend/Dockerfile.prod
push: true
tags: registry.pixelpoint.io/snipsnap-templates-frontend:latest
deploy:
runs-on: ubuntu-latest
needs: build
env:
KUBERNETES_URL: ${{ secrets.KUBERNETES_URL }}
KUBERNETES_TOKEN: ${{ secrets.KUBERNETES_TOKEN }}
steps:
- name: Pull deployment plugin
run: docker pull peloton/drone-k8s-deployment
# TODO: wrap Drone plugin as a Github action, have not found any available solutions
# in the marketplace that could just redeploy
- name: Deploy
run: |
docker run --rm -e PLUGIN_URL=$KUBERNETES_URL -e PLUGIN_TOKEN=$KUBERNETES_TOKEN -e PLUGIN_DEPLOYMENT_NAMES=templates-frontend -e PLUGIN_CONTAINER_NAMES=templates-frontend -e PLUGIN_NAMESPACES=snipsnap -e PLUGIN_DOCKER_IMAGE=registry.pixelpoint.io/snipsnap-templates-frontend:latest -e PLUGIN_DATE_LABEL=deployment.github/date-deployed peloton/drone-k8s-deployment