Skip to content

Deploy to SMR

Deploy to SMR #30

Workflow file for this run

name: Deploy to SMR
on:
workflow_dispatch:
inputs:
should_upload:
type: boolean
default: true
dev_run:
type: boolean
default: false
workflow_call:
secrets:
SMR_API_KEY:
required: true
SMR_API_KEY_DEV:
required: false
RELEASE_WEBHOOK_URL:
required: true
permissions:
actions: read
contents: write
jobs:
deploy-to-smr:
name: Deploy to SMR
runs-on: ubuntu-latest
steps:
- name: Find Release
if: ${{inputs.should_upload}}
uses: actions/github-script@v7
id: find-release
with:
script: |
const response = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 1,
});
const release = response.data[0];
if (!${{inputs.dev_run == true}} && release.draft) {
core.setFailed('Found Release is a draft!');
return;
}
core.setOutput('body', release.body.replaceAll("*", "*"));
core.setOutput('name', release.name);
- name: Download FicsIt-Networks Version
if: ${{inputs.should_upload}}
uses: robinraju/[email protected]
with:
latest: true
fileName: "FicsItNetworks.zip"
- name: Setup FicsIt-CLI
if: ${{inputs.should_upload}}
run: |
wget https://github.com/satisfactorymodding/ficsit-cli/releases/latest/download/ficsit_linux_amd64.deb
sudo dpkg -i ficsit_linux_amd64.deb
- name: Upload to SMR
if: ${{inputs.should_upload}}
env:
BODY: ${{steps.find-release.outputs.body}}
run: |
ficsit ${{ inputs.dev_run && '--api-base https://api.ficsit.dev' || '' }} --api-key "${{ inputs.dev_run && secrets.SMR_API_KEY_DEV || secrets.SMR_API_KEY }}" smr upload ${{ inputs.dev_run && '27CoRS8wTsW1wD' || '8d8gk4imvFanRs'}} FicsItNetworks.zip "$BODY"
- name: Wait for Approval
uses: actions/github-script@v7
with:
script: |
while (true) {
await new Promise(resolve => setTimeout(resolve, 5000));
let response = await fetch("https://api.ficsit.app/v2/query", {
method: "POST",
headers: {"Cookies": "token=${{ inputs.dev_run && secrets.SMR_API_KEY_DEV || secrets.SMR_API_KEY }}", "Content-Type":"application/json"},
body: JSON.stringify({
query: '{getModByReference(modReference:"FicsItNetworks"){versions(filter:{order_by:created_at}){version approved virustotal_results{safe}}}}'
})
})
if (!response.ok) {
console.log(`Checking Fetch: Response is not OK: ${response.status}`);
} else {
const json = await response.json();
let mod = json.data.getModByReference.versions[0];
if (mod.version != '${{steps.find-release.outputs.name}}') {
console.log("Version not yet found...");
continue;
}
let unsafe = mod.virustotal_results.find(virus => !virus.safe);
if (mod.approved && !unsafe) {
console.log("Version got approved!");
return;
}
console.log("Version not approved yet");
}
}
send-discord-release-message:
needs: deploy-to-smr
if: ${{!inputs.dev_run}}
uses: ./.github/workflows/send-discord-release.yml
secrets:
RELEASE_WEBHOOK_URL: ${{ secrets.RELEASE_WEBHOOK_URL }}