-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (80 loc) · 2.84 KB
/
node.js.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
# This workflow will do a clean installation 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: Node.js Client + Server build
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- run: yarn install --frozen-lockfile
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build client
working-directory: ./packages/client
run: yarn build
- name: Build server
working-directory: ./packages/server
run: yarn build
- name: Run server tests
working-directory: ./packages/server
run: yarn test
- name: Do a server dry run
working-directory: ./packages/server
run: yarn dev --dry
- name: Upload server artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3.1.0
with:
name: server-${{ steps.vars.outputs.sha_short }}
path: ./packages/server/dist/
- name: Upload client artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3.1.0
with:
name: client-${{ steps.vars.outputs.sha_short }}
path: ./packages/client/dist/
docker-server:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set version string
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Store version to a file
run: echo "${{ steps.vars.outputs.sha_short }}" > ./packages/server/version.txt
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push server container - PR to main
if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@v3
with:
context: ./
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/rts:server-pr-${{ steps.vars.outputs.sha_short }}
-
name: Build and push server container - main branch
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@v3
with:
context: ./
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/rts:server, ${{ secrets.DOCKERHUB_USERNAME }}/rts:server-${{ steps.vars.outputs.sha_short }}