Skip to content

Workflow

Workflow #326

Workflow file for this run

name: Workflow
on:
workflow_dispatch:
repository_dispatch:
schedule:
- cron: "0 12 * * *" # Everyday at 12:00 UTC
jobs:
Job_U:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: |
npm install -g cytrus-v6
- name: Get Dofus version
run: |
cytrus-v6 download --game dofus --select "VERSION" --output data/U/
export DOFUS_VERSION=$(cat data/U/VERSION)
echo "::set-env name=DOFUS_VERSION::$DOFUS_VERSION"
echo The current Dofus version is $DOFUS_VERSION
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- name: Get Datafus version
run: |
export DATAFUS_VERSION=$(curl https://api.github.com/repos/bot4dofus/Datafus/releases/latest | jq -r ".name")
echo "::set-env name=DATAFUS_VERSION::$DATAFUS_VERSION"
echo The latest Datafus version is $DATAFUS_VERSION
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- name: Stop workflow if no new version
uses: actions/github-script@v6
with:
script: |
if(process.env.DOFUS_VERSION == process.env.DATAFUS_VERSION) {
core.info("Dofus and Datafus versions are the same. No new version. Stopping the workflow.");
const delay = ms => new Promise(res => setTimeout(res, ms));
github.rest.actions.cancelWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId
});
while (true) {
core.info('Waiting for workflow to cancel ...');
await delay(5000);
}
}
- name: U1 - Update Dofus Client
run: |
cytrus-v6 download --game dofus --select "DofusInvoker.swf,**/*.d2i,**/*.d2o" --output data/U/
- name: Upload files
uses: actions/upload-artifact@v3
with:
name: Job_U
path: |
data/U/
Job_A:
runs-on: ubuntu-latest
needs: [Job_U]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: Job_U
path: data/U/
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: A1 - Extract DofusInvoker.swf
run: |
chmod +x src/A1.sh
src/A1.sh data/U/DofusInvoker.swf data/A/DofusInvoker/
- name: A2 - Build .json
run: |
python src/A2.py data/A/DofusInvoker/scripts/com/ data/A/events.json
- name: Upload files
uses: actions/upload-artifact@v3
with:
name: Job_A
path: |
data/A/
Job_B:
runs-on: ubuntu-latest
needs: [Job_U]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: Job_U
path: data/U/
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: B1 - Build .json
run: |
rm data/B/entities_json/*
python src/B1.py data/U/data/common/ data/B/entities_json/
- name: Upload files
uses: actions/upload-artifact@v3
with:
name: Job_B
path: |
data/B/
Job_C:
runs-on: ubuntu-latest
needs: [Job_U]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: Job_U
path: data/U/
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: C1 - Build .json
run: |
python src/C1.py data/U/data/i18n/ data/C/translations_json/
- name: Upload files
uses: actions/upload-artifact@v3
with:
name: Job_C
path: |
data/C/
Job_P:
runs-on: ubuntu-latest
needs: [Job_A, Job_B, Job_C]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Remove data folder
run: |
rm -r data/
- name: Download files Job U
uses: actions/download-artifact@v3
with:
name: Job_U
path: data/U/
- name: Download files Job A
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: Job_A
path: data/A/
- name: Download files Job B
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: Job_B
path: data/B/
- name: Download files Job C
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: Job_C
path: data/C/
- name: Get latest Dofus version
run: |
export DOFUS_VERSION=$(cat data/U/VERSION)
echo The current Dofus version is $DOFUS_VERSION
echo "::set-env name=VERSION::$DOFUS_VERSION"
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- name: Create zip file
run: |
zip -r data.zip data/A/ data/B/ data/C/
- name: Split entities json
run: |
chmod +x devscript/split.sh
./devscript/split.sh data/B/entities_json/
- name: Commit and push
uses: EndBug/add-and-commit@v9
with:
add: '["data/A/", "data/B/", "data/C/"]'
message: 'Update ${{ env.VERSION }}'
push: true
- name: Publish release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ env.VERSION }}
prerelease: false
title: ${{ env.VERSION }}
files: |
./data.zip