forked from frzyc/genshin-optimizer
-
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.
Add build/deployment workflows for Somnia (frzyc#2343)
* Adjust Somnia to be deployable * Add or update the Azure App Service build and deployment workflow config * Add somnia build CI * Fix build * Add deployment step * Fix issues * Fix issue * Fix usage * Fix issues * Simplify build * Add yarnrc timeout override * Remove eslint rules * Fix issues * Fix typo * Fix lint * Fix merge * Add port listen * Add comment * Add PR comment * Add other outputs * Missed one reference to config.json [safe because it never exposed token in build]
- Loading branch information
1 parent
00e5eb2
commit 500a860
Showing
30 changed files
with
3,311 additions
and
396 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: Build Somnia | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
paths-ignore: | ||
- 'apps/frontend/**' | ||
- 'apps/frontend-e2e/**' | ||
- 'apps/gi-frontend/**' | ||
- 'apps/gi-frontend-e2e/**' | ||
- 'apps/sr-frontend/**' | ||
- 'apps/sr-frontend-e2e/**' | ||
- 'libs/common/database-ui/**' | ||
- 'libs/common/img-util/**' | ||
- 'libs/common/react-util/**' | ||
- 'libs/common/svgicons/**' | ||
- 'libs/common/ui/**' | ||
- 'libs/gi/art-scanner/**' | ||
- 'libs/gi/assets/**' | ||
- 'libs/gi/char-cards/**' | ||
- 'libs/gi/db-ui/**' | ||
- 'libs/gi/formula-ui/**' | ||
- 'libs/gi/frontend-gql/**' | ||
- 'libs/gi/i18n/**' | ||
- 'libs/gi/page-*/**' | ||
- 'libs/gi/prisma-schema/**' | ||
- 'libs/gi/silly-wisher/**' | ||
- 'libs/gi/silly-wisher-names/**' | ||
- 'libs/gi/solver/**' | ||
- 'libs/gi/solver-tc/**' | ||
- 'libs/gi/supabase/**' | ||
- 'libs/gi/svgicons/**' | ||
- 'libs/gi/ui/**' | ||
- 'libs/gi/uidata/**' | ||
- 'libs/gi/wr/**' | ||
- 'libs/sr/assets/**' | ||
- 'libs/sr/i18n/**' | ||
- 'libs/sr/page-*/**' | ||
- 'libs/sr/solver/**' | ||
- 'libs/sr/ui/**' | ||
types: [opened, reopened, synchronize, labeled] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get Cache Key | ||
id: get-cache-key | ||
run: | | ||
echo "key=$(git ls-tree -r HEAD | grep '^160000' | sha256sum | cut -d " " -f 1)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache/restore@v4 | ||
with: | ||
path: .git/modules | ||
key: submodule-${{ steps.get-cache-key.outputs.key }} | ||
restore-keys: | | ||
submodule- | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
submodules: true | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'yarn' | ||
- name: Yarn install | ||
run: | | ||
yarn install --immutable --immutable-cache | ||
- name: Build Somnia | ||
run: | | ||
NX_DAEMON="false" | ||
cp apps/somnia/src/config.empty.json apps/somnia/src/config.json | ||
yarn run nx run somnia:build:production | ||
- name: echos | ||
run: | | ||
if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then | ||
echo "somnia-prod" > environment | ||
else | ||
echo "somnia-test" > environment | ||
fi | ||
echo $(git rev-parse HEAD) > ref | ||
echo ${{ contains(github.event.pull_request.labels.*.name, 'deploySomnia') }} > shouldDeploy | ||
echo ${{ github.event.number }} > pr_number | ||
- name: Archive build | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: somnia_build | ||
path: | | ||
dist/apps/somnia | ||
environment | ||
ref | ||
shouldDeploy | ||
pr_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,79 @@ | ||
name: Deploy Somnia from artifact | ||
run-name: Deploy Somnia from artifact created by "${{ github.event.workflow_run.display_title }}" | ||
|
||
on: | ||
workflow_run: | ||
workflows: | ||
- Build Somnia | ||
types: | ||
- completed | ||
|
||
jobs: | ||
set-env: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
env: ${{ steps.set_env.outputs.env }} | ||
shouldDeploy: ${{ steps.set_env.outputs.shouldDeploy }} | ||
prNumber: ${{ steps.set_env.outputs.prNumber }} | ||
ref: ${{ steps.set_env.outputs.ref }} | ||
steps: | ||
- name: Download build artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
run-id: ${{ github.event.workflow_run.id }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Set env | ||
id: set_env | ||
run: | | ||
echo "env=$(cat somnia_build/environment)" >> $GITHUB_OUTPUT | ||
echo "shouldDeploy=$(cat somnia_build/shouldDeploy)" >> $GITHUB_OUTPUT | ||
echo "prNumber=$(cat somnia_build/prNumber)" >> $GITHUB_OUTPUT | ||
echo "ref=$(cat somnia_build/ref)" >> $GITHUB_OUTPUT | ||
deploy: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
needs: set-env | ||
environment: | ||
name: ${{ needs.set-env.outputs.env }} | ||
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | ||
permissions: | ||
id-token: write # This is required for requesting the JWT | ||
if: ${{ github.event.workflow_run.conclusion == 'success' && (needs.set-env.outputs.shouldDeploy == 'true' || needs.set-env.outputs.env == 'somnia-prod') }} | ||
steps: | ||
- name: Download build artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
run-id: ${{ github.event.workflow_run.id }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Login to Azure | ||
uses: azure/login@v2 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
- name: Setup config.json and others | ||
run: | | ||
printf '%s' "$CONFIG" > somnia_build/dist/apps/somnia/apps/somnia/src/config.json | ||
echo ${{ needs.set-env.outputs.ref }} > somnia_build/dist/apps/somnia/ref | ||
echo ${{ needs.set-env.outputs.prNumber }} > somnia_build/dist/apps/somnia/prNumber | ||
env: | ||
CONFIG: ${{ secrets.SOMNIA_CREDENTIALS }} | ||
- name: 'Deploy to Azure Web App' | ||
id: deploy-to-webapp | ||
uses: azure/webapps-deploy@v3 | ||
with: | ||
app-name: ${{ vars.ENV_NAME }} | ||
slot-name: 'Production' | ||
package: somnia_build/dist/apps/somnia | ||
- name: Output date | ||
id: output-date | ||
run: echo "date=$(date -u)" >> $GITHUB_OUTPUT | ||
- name: Maintain comment | ||
uses: actions-cool/maintain-one-comment@v3 | ||
if: ${{ needs.set-env.outputs.prNumber != '' }} | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
number: ${{ needs.set-env.outputs.prNumber }} | ||
body: | | ||
[${{ needs.set-env.outputs.env }}] [${{ steps.output-date.outputs.date }}] - Deployed ${{ needs.set-env.outputs.ref }} to ${{ needs.set-env.outputs.env }}" >> $GITHUB_OUTPUT | ||
body-include: '<!-- Created by actions-cool/maintain-one-comment -->' | ||
update-mode: 'append' |
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 @@ | ||
network-timeout 240000 |
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,7 @@ | ||
{ | ||
"name": "somnia", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"start": "node main.js" | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"executors": { | ||
"gen-assets-data": { | ||
"implementation": "./src/executors/gen-assets-data/executor", | ||
"schema": "./src/executors/gen-assets-data/schema.json", | ||
"description": "gen-assets-data executor" | ||
} | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"name": "@genshin-optimizer/gi/assets-data", | ||
"version": "0.0.1", | ||
"type": "commonjs", | ||
"executors": "./executors.json" | ||
} |
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.