-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (87 loc) · 2.64 KB
/
web.cd.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
93
94
95
96
97
98
99
name: " WEB [CD]"
on:
push:
branches:
- 'dev'
- 'ops'
- 'main'
paths:
- "build/package/web/Dockerfile"
- '**/*.js'
- '**/*.json'
- '**/*.vue'
- "web/"
jobs:
BUILD:
name: BUILD
runs-on: ubuntu-latest
env:
wd: web/
steps:
# Checkout to current workspace
- name: 1 - CHECKOUT
uses: actions/checkout@v3
with:
fetch-depth: 0
# Install Golang with specific version
- name: 2 - SETUP NODE@16
uses: actions/setup-node@v3
with:
node-version: 16
# Cache Go modules to make the build faster
- name: 3 - GET NPM CACHE DIRECTORY
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: 4 - CACHE NODE MODULES
uses: actions/cache@v3
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# Install packages
- name: 5 - NPM INSTALL
run: npm install
working-directory: ${{ env.wd }}
# Build apps
- name: 4 - BUILD
run: npm run build
working-directory: ${{ env.wd }}
RELEASE:
name: RELEASE
needs: BUILD
runs-on: ubuntu-latest
steps:
# Checkout to current workspace
- name: 1 - CHECKOUT
uses: actions/checkout@v3
with:
fetch-depth: 0
# Login to container registry
- name: 2 - LOGIN TO GHCR.IO
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Setup custom tag name
- name: 3 - SETUP ENV VARS
run: |
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | head -c8)" >> $GITHUB_ENV
echo "CURRENT_DATE=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "BRANCH_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV
# Build and push the app with given file and tag
- name: 4 - BUILD + PUSH
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
push: true
file: build/package/web/Dockerfile
target: production
tags: |
ghcr.io/gogolcorp/go-yave_web:${{ env.BRANCH_NAME }}-${{ env.GITHUB_SHA_SHORT }}-${{ env.CURRENT_DATE }}
ghcr.io/gogolcorp/go-yave_web:${{ env.BRANCH_NAME }}-${{ env.GITHUB_SHA_SHORT }}
ghcr.io/gogolcorp/go-yave_web:latest