-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from NMSCD/dev
Update to WorldsOne
- Loading branch information
Showing
23 changed files
with
4,893 additions
and
870 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
name: Build | ||
|
||
run-name: Build Code | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
|
||
permissions: | ||
contents: write | ||
|
||
concurrency: | ||
group: 'build-deploy' | ||
cancel-in-progress: true | ||
|
||
# You should only need to touch these two variables | ||
env: | ||
buildCommand: | | ||
npm ci | ||
npm run build | ||
buildOutput: dist # optionally "dist" if build step is needed | ||
|
||
jobs: | ||
build-main: | ||
environment: github-pages | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build App | ||
run: ${{ env.buildCommand }} | ||
|
||
- name: Minify Code | ||
uses: Lenni009/minify-js@main | ||
with: | ||
directory: ${{ env.buildOutput }} | ||
overwrite: true | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: main | ||
path: ${{ env.buildOutput }} | ||
|
||
getPRs: | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
prData: ${{ steps.data.outputs.pullRequestData }} | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Deno | ||
uses: denoland/setup-deno@v1 | ||
|
||
- name: Get PR Data | ||
id: data | ||
run: | | ||
data=$(deno run --allow-net .github/workflows/getPRs.ts ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }}) # output: pullRequestData: {ref: string, number: number}[] | ||
echo "pullRequestData=$data" >> "$GITHUB_OUTPUT" | ||
build-pr: | ||
runs-on: ubuntu-latest | ||
needs: getPRs | ||
# GH Actions outputs are strings, so we can just compare this to an empty array string. `.length` does not seem to work when parsing the array. | ||
if: needs.getPRs.outputs.prData != '[]' | ||
|
||
strategy: | ||
matrix: | ||
data: ${{ fromJSON(needs.getPRs.outputs.prData) }} | ||
|
||
steps: | ||
- name: Checkout PR branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ matrix.data.ref }} | ||
|
||
- name: Add Base Path to Vite Config | ||
run: echo 'VITE_BASE_PATH=/pr/${{ matrix.data.number }}/' > .env | ||
|
||
- name: Build App | ||
run: ${{ env.buildCommand }} | ||
|
||
- name: Minify Code | ||
uses: Lenni009/minify-js@main | ||
with: | ||
directory: ${{ env.buildOutput }} | ||
overwrite: true | ||
|
||
- name: Upload App | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.data.number }} | ||
path: ${{ env.buildOutput }} | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
if: ${{ !cancelled() && !failure() }} | ||
needs: ['build-main', 'build-pr'] | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download App | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: dist/pr | ||
|
||
- name: Move Main Deployment | ||
run: | | ||
cd dist | ||
cp -r pr/main/* . | ||
rm -rf pr/main | ||
touch .nojekyll | ||
- name: Deploy | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
folder: dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Deploy PR | ||
|
||
run-name: Deploy PR | ||
|
||
on: | ||
pull_request: | ||
types: ["opened", "synchronize"] | ||
branches: ["main"] | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build App | ||
run: | | ||
echo 'VITE_BASE_PATH=/pr/${{ github.event.number }}/' > .env | ||
npm ci | ||
npm run build | ||
- name: Minify Code | ||
uses: Lenni009/minify-js@main | ||
with: | ||
directory: dist | ||
overwrite: true | ||
|
||
- name: Get GH Pages URL | ||
id: pages | ||
uses: actions/configure-pages@v5 | ||
|
||
- name: Deploy | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
folder: dist | ||
target-folder: "pr/${{ github.event.number }}" # The folder the action should deploy to. | ||
|
||
- name: Add PR Comment | ||
uses: mshick/add-pr-comment@v2 | ||
with: | ||
message: "Deployed to ${{ steps.pages.outputs.base_url }}/pr/${{ github.event.number }}/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import core from 'npm:@actions/core'; | ||
import github from 'npm:@actions/github'; | ||
import { RestEndpointMethodTypes } from 'npm:@octokit/plugin-rest-endpoint-methods'; | ||
|
||
type PRListResponse = RestEndpointMethodTypes['pulls']['list']['response']; | ||
|
||
async function listPullRequests(token: string, repoOwner: string, repo: string, state: 'open' | 'closed' | 'all') { | ||
const octokit = github.getOctokit(token); | ||
const pullRequests = await octokit.rest.pulls.list({ | ||
repo, | ||
state, | ||
owner: repoOwner, | ||
sort: 'created', | ||
direction: 'desc', | ||
per_page: 100, | ||
}); | ||
return pullRequests; | ||
} | ||
|
||
function outputRefs(list: PRListResponse) { | ||
const prDataList = list.data.map((p) => ({ | ||
ref: p.head.ref, | ||
number: p.number, | ||
})); | ||
console.log(prDataList); | ||
} | ||
|
||
try { | ||
const [repoData, token] = Deno.args; | ||
const [repoOwner, repo] = repoData.split('/'); | ||
const state = 'open'; | ||
|
||
const list = await listPullRequests(token, repoOwner, repo, state); | ||
outputRefs(list); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.