forked from governify/registry
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (124 loc) · 4.21 KB
/
nodejs.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
name: Build and Publish Docker Image
on:
push:
branches:
- main
- develop
tags:
- "*.*.*"
pull_request:
branches:
- main
- develop
types:
- labeled
env:
REGISTRY_IMAGE: governify/registry
GHCR_IMAGE: governify/registry
PR_ID: ${{ github.event.pull_request.number }}
TAG: ${{ github.ref_name }}
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- name: Checkout repository ⬇️
uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }} 📦🛠️
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies 📦⬇️
run: npm install
- name: Start the server 🚀
run: npm start &
# - name: Check server is running 🏃
# run: curl -f http://localhost:5800/docs || exit 1
test:
name: Lint, test and coverage to coveralls 🧪
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test
env:
CI: true
- name: Generate coverage report
run: npm run coverage
env:
CI: true
- name: Coverage to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
CI: true
docker:
runs-on: ubuntu-latest
needs: test
if: ((github.event.pull_request && github.event.label.name == '🐳 Dockerize') || github.event_name == 'push') && startsWith(github.repository, 'governify/')
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout ⬇️
uses: actions/checkout@v4.2.2
with:
show-progress: false
- name: Configure QEMU ⚙️
uses: docker/setup-qemu-action@v3.2.0
- name: Configure Docker Buildx ⚙️
uses: docker/setup-buildx-action@v3.7.1
- name: Login to DockerHub 🔑
uses: docker/login-action@v3.3.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry 🔑
uses: docker/login-action@v3.3.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v6.10.0
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
${{ startsWith(github.ref, 'refs/tags/') && format('{0}:{1}', env.REGISTRY_IMAGE, env.TAG) || '' }}
${{ github.ref == 'refs/heads/main' && format('{0}:latest', env.REGISTRY_IMAGE) || '' }}
${{ github.ref == 'refs/heads/develop' && github.event_name == 'push' && format('{0}:develop', env.REGISTRY_IMAGE) || '' }}
${{ github.event_name == 'pull_request' && format('{0}:PR.{1}', env.REGISTRY_IMAGE, env.PR_ID) || '' }}
- name: Build and Push Ghcr Image
uses: docker/build-push-action@v6.10.0
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
${{ startsWith(github.ref, 'refs/tags/') && format('ghcr.io/{0}:{1}', env.GHCR_IMAGE, env.TAG) || '' }}
${{ github.ref == 'refs/heads/main' && format('ghcr.io/{0}:latest', env.GHCR_IMAGE) || '' }}
${{ github.ref == 'refs/heads/develop' && github.event_name == 'push' && format('ghcr.io/{0}:develop', env.GHCR_IMAGE) || '' }}
${{ github.event_name == 'pull_request' && format('ghcr.io/{0}:PR.{1}', env.GHCR_IMAGE, env.PR_ID) || '' }}