-
Notifications
You must be signed in to change notification settings - Fork 27
105 lines (100 loc) · 4.05 KB
/
build.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
name: Build and deploy to Kuroco front
on:
push:
branches:
- main
issue_comment:
types: [created, edited]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# for Pull Request (exclude merged)
pullreq_build:
name: Build(pullreq)
if: (github.repository == 'diverta/front_nuxt_auth' && github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/kuroco stage') && github.event.issue.pull_request != null)
runs-on: ubuntu-latest
steps:
- name: "Get branch name and sha"
id: get_branch
run: |
PR=$(curl -H "X-Kuroco-Auth: token 79a0dac07eb8af664820afa615e28575" https://dev-nuxt-auth.a.kuroco.app/direct/menu/github/?pr=${{ github.event.issue.pull_request.url }})
echo "branch=$(echo $PR | jq -r '.ref')" >> $GITHUB_OUTPUT
echo "sha=$(echo $PR | jq -r '.sha')" >> $GITHUB_OUTPUT
- name: Checkout Repo
uses: actions/checkout@v4
with:
ref: ${{ steps.get_branch.outputs.branch }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: CI Cache
uses: actions/cache@v4
id: node_modules_cache_id
env:
cache-name: cache-node-modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.ref_name }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: ${{ steps.node_modules_cache_id.outputs.cache-hit != 'true' }}
run: npm ci
- name: Generate
run: npm run generate
- name: Zip artifact for upload
run: cd ./.output/public && zip ../../dist.zip . -r
- name: Archive Production Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.get_branch.outputs.sha }}-${{ github.run_id }}
path: dist.zip
retention-days: 1
- name: Wait for Artifact download
run: sleep 15
- name: Webhook
uses: diverta/workflow-webhook@v3
env:
webhook_url: "https://dev-nuxt-auth.a.kuroco.app/direct/menu/github/"
webhook_secret: "79a0dac07eb8af664820afa615e28575"
data: '{"single_zip":"1","domain":"dev-nuxt-auth.g.kuroco-front.app","pr":"${{ github.event.issue.pull_request.url }}", "repository":"${{ github.repository }}", "run_id":"${{ github.run_id }}", "hash":"${{ steps.get_branch.outputs.sha }}"}'
#for Push
pushed_build:
name: Build(pushed)
if: (github.repository == 'diverta/front_nuxt_auth' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch'))
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: CI Cache
uses: actions/cache@v4
id: node_modules_cache_id
env:
cache-name: cache-node-modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.ref_name }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: ${{ steps.node_modules_cache_id.outputs.cache-hit != 'true' }}
run: npm ci
- name: Generate
run: npm run generate
- name: Zip artifact for upload
run: cd ./.output/public && zip ../../dist.zip . -r
- name: Archive Production Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ github.run_id }}
path: dist.zip
retention-days: 7
- name: Webhook
uses: diverta/workflow-webhook@v3
env:
webhook_url: "https://dev-nuxt-auth.a.kuroco.app/direct/menu/github/"
webhook_secret: "79a0dac07eb8af664820afa615e28575"
data: '{"single_zip":"1","domain":"dev-nuxt-auth.g.kuroco-front.app", "repository":"${{ github.repository }}", "run_id":"${{ github.run_id }}", "hash":"${{ github.sha }}"}'