Merge branch 'main' of https://github.com/C0C0B01/Pupu
This commit is contained in:
commit
97a8d15bb7
3 changed files with 160 additions and 2 deletions
87
.github/workflows/build.yaml
vendored
Normal file
87
.github/workflows/build.yaml
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
name: Node.js CI / CD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
buildAndRelease:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [20.x]
|
||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: latest
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
id: pnpm-cache
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- run: |
|
||||
pnpm build --release-branch=${{ github.ref_name }} --build-minify
|
||||
|
||||
# - name: Create Release
|
||||
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
# uses: actions/create-release@v1
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# with:
|
||||
# tag_name: v${{ github.run_number }}
|
||||
# release_name: Release v${{ github.run_number }}
|
||||
# draft: false
|
||||
# prerelease: false
|
||||
|
||||
- name: Push JS files to dist branch
|
||||
run: |
|
||||
# Configure git
|
||||
git config --local user.email "actions@github.com"
|
||||
git config --local user.name "GitHub Actions"
|
||||
|
||||
# Create a temporary directory for the dist branch
|
||||
mkdir -p temp_dist
|
||||
|
||||
# Copy only JS files from dist/ to temp directory
|
||||
find dist -name "*.js" -exec cp {} temp_dist/ \;
|
||||
|
||||
# Create and checkout dist branch
|
||||
git checkout --orphan dist-temp
|
||||
git rm -rf --cached .
|
||||
|
||||
# Move the JS files to the root
|
||||
cp -r temp_dist/* .
|
||||
rm -rf temp_dist
|
||||
|
||||
# Add, commit and push to dist branch
|
||||
git add *.js
|
||||
git commit -m "Update build $GITHUB_SHA" || exit 0
|
||||
git push -f origin HEAD:dist
|
||||
|
||||
# Return to the original branch
|
||||
git checkout -f ${GITHUB_REF#refs/heads/}
|
||||
71
.github/workflows/codeql.yml
vendored
Normal file
71
.github/workflows/codeql.yml
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
name: "CodeQL Advanced"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main", "dev" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
schedule:
|
||||
- cron: '31 8 * * 6'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
security-events: write
|
||||
packages: read
|
||||
actions: read
|
||||
contents: read
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'javascript-typescript' ]
|
||||
node-version: [20.x]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: latest
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
id: pnpm-cache
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
build-mode: none
|
||||
|
||||
- name: Build project
|
||||
run: pnpm build --release-branch=${{ github.ref_name }} --build-minify
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
|
|
@ -28,8 +28,8 @@ Please do not donate if you are not able to, if you are able to please don't don
|
|||
pnpm build
|
||||
```
|
||||
1. In the newly created `dist` directory, run a HTTP server. I recommend [http-server](https://www.npmjs.com/package/http-server).
|
||||
1. Go to Settings > Developer enabled earlier. Enable `Load from custom url` and input the IP address and port of the server (e.g. `http://192.168.1.236:4040/pupu.js`) in the new input box labelled `Pupu URL`.
|
||||
1. Restart Discord. Upon reload, you should notice that your device will download Pupu's bundled code from your server, rather than GitHub.
|
||||
1. Go to Settings > Developer enabled earlier. Enable `Load from custom url` and input the IP address and port of the server (e.g. `http://192.168.1.236:4040/kettu.js`) in the new input box labelled `Kettu URL`.
|
||||
1. Restart Discord. Upon reload, you should notice that your device will download Kettu's bundled code from your server, rather than GitHub.
|
||||
1. Make your changes, rebuild, reload, go wild!
|
||||
|
||||
Alternatively, you can directly *serve* the bundled code by running `pnpm serve`. `kettu.js` will be served on your local address under the port 4040. You will then insert `http://<local ip address>:4040/kettu.js` as a custom url and reload. Whenever you restart your mobile client, the script will rebuild the bundle as your client fetches it.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue