-
Notifications
You must be signed in to change notification settings - Fork 4
149 lines (144 loc) · 4.7 KB
/
build_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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: build CoderBot frontend
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'
- name: Docker login
run: docker login ghcr.io -u previ -p ${{ secrets.GHCR_BACKEND_STUB_RO }}
- name: Run stub
run: docker run -dp 5000:5000 --name backend-stub ghcr.io/coderbotorg/backend:stub-latest
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v6
with:
#build: npm run build-test
start: npm run test
wait-on: 'http://localhost:5000/api/v1/openapi.json'
wait-on-timeout: 60
browser: chrome
record: true
parallel: true
group: 'UI - Chrome'
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean up
run: docker stop backend-stub && docker rm backend-stub
- name: Archive coverage
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage
build:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- name: Archive dist
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
- name: Create Release
if: ${{ github.ref_type == 'tag' }}
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
draft: ${{ contains( github.ref_name, 'rc') }}
prerelease: false
- name: Create archive
if: ${{ github.ref_type == 'tag' }}
run: tar czf frontend.tar.gz dist
- name: Upload Built Frontend
if: ${{ github.ref_type == 'tag' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: frontend.tar.gz
asset_name: frontend.tar.gz
asset_content_type: application/gzip
- uses: eregon/publish-release@v1
if: ${{ github.ref_type == 'tag' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4 # Checking out the repo
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: ghcr.io/coderbotorg/frontend
# generate Docker tags based on the following events/attributes
tags: |
# always latest
type=raw,value=latest
# branch event
type=ref,event=branch
# tag event
type=ref,event=tag
# pull request event
type=ref,event=pr
# push event
type=sha,enable=true,prefix=git-,format=short
- name: Download dist artifact
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- run: wget https://github.com/CoderBotOrg/docs/releases/download/v0.2/docs.tgz
- run: mkdir -p cb_docs
- run: tar xzf docs.tgz -C cb_docs
- run: rm docs.tgz
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/arm/v7
tags: ${{ steps.meta.outputs.tags }}
context: .
file: docker/Dockerfile
cache-from: type=registry,ref=ghcr.io/coderbotorg/frontend:latest
cache-to: type=inline