-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (142 loc) · 3.77 KB
/
Copy pathci-cd-5.yml
File metadata and controls
148 lines (142 loc) · 3.77 KB
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
name: CI-CD 5
on:
pull_request:
types: [opened, reopened]
issues:
types: [opened]
workflow_dispatch:
push:
branches:
- main
- dev
env:
GLOBAL_TOKEN: supersecretglobaltoken
jobs:
lint:
runs-on: ubuntu-latest
container:
image: node:20.11.1
env:
NODE_PORT: 3680
# REDIS_HOST: myredis
# REDIS_PORT: 6379
environment:
name: staging
services:
myredis:
image: redis
ports:
- 6379:6379
env:
HYPER_TOKEN: claudeanthropic2020
# NODE_PORT: 3680
# REDIS_HOST: 127.0.0.1
# REDIS_PORT: 6379
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Log token
run: |
echo "Claude token: ${{ env.HYPER_TOKEN }}"
echo "Global token: ${{ env.GLOBAL_TOKEN }}"
echo "Repository secret token: ${{ secrets.HYPER_SECRET_TOKEN }}"
echo "Repository variable: ${{ vars.HYPER_REPO_VARIABLE }}"
echo "Without interpolation: $HYPER_TOKEN"
echo "Node PORT from container: $NODE_PORT"
echo "Redis host: $REDIS_HOST and port: $REDIS_PORT"
- name: Run a nodejs script (script.js)
run: node script.cjs
env:
REDIS_HOST: myredis
REDIS_PORT: 6379
test:
needs: lint
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: 20.11.1
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Test
run: npm run test
build:
needs: test
runs-on: ubuntu-latest
outputs:
jsfile: ${{ steps.publishedjs.outputs.jsfile }}
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: 20.11.1
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Upload important files
uses: actions/upload-artifact@v4
with:
name: assets
path: |
public
package-lock.json
package.json
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
- name: Publish packaged js filename
id: publishedjs
run: find dist/assets/*.js -type f -execdir echo 'jsfile={}' >> $GITHUB_OUTPUT ';'
deploy:
needs: build
runs-on: ubuntu-latest
env:
JSFILE: ${{ needs.build.outputs.jsfile }}
steps:
- name: Download assets
uses: actions/download-artifact@v4
with:
name: assets
- name: List files
run: ls
- name: Remove all files
run: rm -rf *
- name: List after remove
run: ls
- name: Download build assets
uses: actions/download-artifact@v4
with:
name: dist
- name: List files
run: ls
- name: Print js filename produced from build step
run: echo $JSFILE
- name: Deploy
run: echo "Deploying..."