Skip to content

Traduit à 66.0%

Traduit à 66.0% #1773

Workflow file for this run

name: Build
on:
push:
branches: [ "main" ]
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy'
type: environment
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Downloading English YTTD build
run: curl -Lo yttd.zip https://cdn.vinceh121.me/YourTurnToDie-2023-09-12-01f89eddf5a0e204422984ab574a631c25f3b098fda068bb3eaaa77155e932ac.zip
- name: Unzipping English YTTD build
run: unzip yttd.zip -d yttd
- name: Installing required JavaScript dependencies
run: npm i
working-directory: tools
- name: Compressing fr.json into FR.cte
run: node tools/compress.js
- name: Moving FR.cte in yttd/www/languages/
run: mv FR.cte yttd/www/languages/
#- name: Editing data/animations.json 2-EN -> 2-FR
# run: sed -i 's/EN/FR/' yttd/www/data/Animations.json
- name: Patching plugins.js
run: |
sed -i 's/"LanguageCodes":"\[/"LanguageCodes":"[\\"FR\\",/' yttd/www/js/plugins.js
sed -i 's/"DefaultLanguage":"EN"/"DefaultLanguage":"FR"/' yttd/www/js/plugins.js
- name: Balance Battle Horizontal Text Patching in yttd/www/js/plugins/CustomTranslationEngine.js
run: sed -i 's/var horizontalLanguages = \[ "EN" \];/var horizontalLanguages = \[ "EN", "FR" \];/g' yttd/www/js/plugins/CustomTranslationEngine.js
# - name: Patching Animations.json
# run: node tools/apply-animation-patch.mjs
- name: Copy Animations.json
run: cp assets/Animations.json yttd/www/data/Animations.json
- name: Patching images
run: node tools/crypt.js
- name: Uploading build artefacts
uses: actions/upload-artifact@v4
with:
name: yttd-www
path: yttd/www
package:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
include:
- platform: win-x64
archive_ext: zip
- platform: linux-x64
archive_ext: tar.gz
- platform: osx-x64
archive_ext: zip
- platform: osx-arm64
archive_ext: zip
env:
NWJS_VERSION: v0.92.0
steps:
# GHA can't self-reference a single envvar map https://stackoverflow.com/a/75433159
- run: |
echo "NWJS_FOLDER=nwjs-${{ env.NWJS_VERSION }}-${{ matrix.platform }}" >> $GITHUB_ENV
- run: |
echo "NWJS_ARCHIVE=${{ env.NWJS_FOLDER }}.${{ matrix.archive_ext }}" >> $GITHUB_ENV
- run: |
echo "YTTD_FOLDER=yttd-${{ matrix.platform }}" >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Download artefacts
uses: actions/download-artifact@v4
- name: Downloading nwjs
run: curl --fail -LO https://dl.nwjs.io/${{ env.NWJS_VERSION }}/$NWJS_ARCHIVE
- name: Extracting nwjs (zip)
run: unzip -d . $NWJS_ARCHIVE
if: ${{ matrix.archive_ext == 'zip' }}
- name: Extracting nwjs (tar.gz)
run: tar xvf $NWJS_ARCHIVE
if: ${{ matrix.archive_ext == 'tar.gz' }}
- run: mv $NWJS_FOLDER $YTTD_FOLDER
- run: mkdir $YTTD_FOLDER/www
- run: mv yttd-www/* $YTTD_FOLDER/www
- run: cp package.nwjs.json $YTTD_FOLDER/package.json
- name: Uploading build artefacts
uses: actions/upload-artifact@v4
with:
name: yttd-${{ github.sha }}-${{ matrix.platform }}
path: ${{ env.YTTD_FOLDER }}
website:
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.environment || 'Production' }}
steps:
- uses: actions/checkout@v3
- run: npm i && npm run build
working-directory: www
env:
WEBLATE_BASE_URL: ${{ secrets.WEBLATE_BASE_URL }}
WEBLATE_TOKEN: ${{ secrets.WEBLATE_TOKEN }}
WEBLATE_AVATAR_BASE_URL: ${{ secrets.WEBLATE_AVATAR_BASE_URL }}
COMMIT_HASH: ${{ github.sha }}
- name: Uploading build artefacts
uses: actions/upload-artifact@v4
with:
name: website
path: www/dist
deploy:
runs-on: ubuntu-latest
needs: [package, website]
environment:
name: ${{ github.event.inputs.environment || 'Production' }}
url: ${{ github.event.inputs.environment == 'Production' && 'https://yttd.fr' || 'https://staging.yttd.fr' }}
concurrency:
group: Production
cancel-in-progress: true
steps:
- name: Download artefacts
uses: actions/download-artifact@v4
with:
path: artifacts
- run: mv artifacts/yttd-www artifacts/yttd
- run: mv artifacts/website/* artifacts/
- run: |
for i in win-x64 linux-x64 osx-x64 osx-arm64
do
zip -r artifacts/yttd-${{ github.sha }}-$i.zip artifacts/yttd-${{ github.sha }}-$i
rm -r artifacts/yttd-${{ github.sha }}-$i
done
- uses: actions/checkout@v3
with:
path: yttdfr
#- name: Install Sentry
# run: |
# curl -Lo artifacts/yttd/js/libs/sentry.js https://browser.sentry-cdn.com/8.37.1/bundle.min.js
# curl -Lo artifacts/yttd/js/libs/sentry-http.js https://browser.sentry-cdn.com/8.37.1/httpclient.min.js
# curl -Lo artifacts/yttd/js/libs/sentry-console.js https://browser.sentry-cdn.com/8.37.1/captureconsole.min.js
# patch artifacts/yttd/index.html yttdfr/index.html.patch
- uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
source: artifacts
target: /tmp/yttd-working
strip_components: 1
overwrite: true
- name: remove existing files
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
script: |
rm -r ${{ secrets.DEPLOY_PATH }}/*
mv /tmp/yttd-working/* ${{ secrets.DEPLOY_PATH }}/
rm -r /tmp/yttd-working