Repository navigation
78 lines (68 loc) · 2.42 KB
/
Copy pathmain.yml
File metadata and controls
78 lines (68 loc) · 2.42 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
# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#
name: Build and Deploy
on:
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
architecture: 'x64' # (x64 or x86)
- name: Get Version ID
id: get-version-id
run: |
VERSION_ID=$(cat package.json | grep version | sed 's| \"version\": \"||g' | sed 's|\",||g')
echo "::set-output name=version-id::$(echo $VERSION_ID)"
echo $VERSION_ID
- name: Install and Build 🔧
env:
VERSION_ID: ${{ steps.get-version-id.outputs.version-id }}
run: |
sed -i "s|publicPath: '/'|publicPath: '//cdn.jsdelivr.net/gh/XCPCIO/XCPCIO-rating-webapp@${{ env.VERSION_ID }}/'|" config.ts
sed -i "s|favicon: '/favicon.png'|favicon: '//cdn.jsdelivr.net/gh/XCPCIO/XCPCIO-rating-webapp@${{ env.VERSION_ID }}/favicon.png'|" config.ts
sed -i "s|baidu: ''|baidu: '${{ secrets.BAIDU_ANALYTICS_ID }}'|" config.ts
cat config.ts
npm install
npm run build
- name: Minify HTML Index
uses: Dup4/minify-html-action@v9
with:
src: './dist/index.html'
- name: Enable 404.html
run: |
cp ./dist/index.html ./dist/404.html
- name: Release Index
uses: JamesIves/github-pages-deploy-action@4.1.5
with:
branch: gh-pages
folder: dist
clean: true
clean-exclude: CNAME
- name: Create Release
id: create_release
uses: actions/create-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION_ID: ${{ steps.get-version-id.outputs.version-id }}
with:
commitish: gh-pages
tag_name: ${{ env.VERSION_ID }}
release_name: Release ${{ env.VERSION_ID }}
draft: false
prerelease: false
- name: Invoke workflow in another repo with inputs
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Update And Commit
repo: XCPCIO/XCPCIO-rating
token: ${{ secrets.GH_TOKEN }}