-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (104 loc) · 3.44 KB
/
webappbuild.yaml
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Web APP CI
on:
push:
paths:
- '**/front/**'
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write # Allows deployment to the GitHub page
id-token: write
packages: write # Allows pushing to the GitHub Container Registry
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: 'actions/checkout@v3'
name: Checkout
with:
persist-credentials: false
- name: Setup Node
uses: 'actions/setup-node@v3'
with:
node-version: 19.x
cache: 'yarn'
cache-dependency-path: './front/yarn.lock'
- name: Install dependencies
run: yarn install --frozen-lockfile
working-directory: './front/'
- name: Lint
run: yarn lint
working-directory: './front/'
- name: Code standard check
run: yarn prettier:check
working-directory: './front/'
- name: Unit tests
run: yarn test:clover
working-directory: './front/'
- name: Build
run: yarn build:ci
working-directory: './front/'
- name: Setup Pages
uses: 'actions/configure-pages@v3'
- name: Build GitHub Page
uses: 'actions/jekyll-build-pages@v1'
with:
source: './front/dist/'
- name: Upload artifact
uses: 'actions/upload-pages-artifact@v1'
deploy:
environment:
name: webapp-page
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: 'actions/deploy-pages@v2'
# todo: add cypress stage before packaging
packaging:
env:
REPOSITORY: ghcr.io/devgine
IMAGE: company-versioning-webapp
VERSION: ${{ github.ref_name }}
runs-on: ubuntu-latest
needs: deploy # todo: update to cypress job when it's created
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: 'actions/checkout@v3'
- name: Set up Depot CLI
uses: 'depot/setup-action@v1'
- name: Login to GitHub Container Registry
uses: 'docker/login-action@v1'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_REPOSITORY_TOKEN }}
# todo: push image with commit sha tag
- name: Process builder
shell: bash
run: |
echo "build_version=dev" >> $GITHUB_ENV
echo "my_docker_image=$REPOSITORY/$IMAGE:dev,$REPOSITORY/$IMAGE:${{ github.sha }}" >> $GITHUB_ENV
echo "build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
- name: Docker image build and push
uses: 'depot/build-push-action@v1'
with:
project: ${{ secrets.DEPOT_PROJECT_ID_WEBAPP }}
token: ${{ secrets.DEPOT_PROJECT_TOKEN_WEBAPP }}
push: true
tags: ${{ env.my_docker_image }}
context: ./front
target: devenv-webapp
build-args: |
VCS_REF=${{ github.sha }}
BUILD_DATE=${{ env.build_date }}
BUILD_VERSION=${{ env.build_version }}