Deploy to SMR #13
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
name: Deploy to SMR | |
on: | |
workflow_dispatch: | |
inputs: | |
should_upload: | |
type: boolean | |
default: true | |
workflow_call: | |
secrets: | |
SMR_API_KEY: | |
required: true | |
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 (release.draft) { | |
core.setFailed('Found Release is a draft!'); | |
return; | |
} | |
core.setOutput('body', release.body); | |
- 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 --api-key "${{secrets.SMR_API_KEY}}" smr upload 8d8gk4imvFanRs FicsItNetworks.zip $body | |
- name: Wait for Approval | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
while (true) { | |
let response = await fetch("https://api.ficsit.app/v2/query", { | |
method: "POST", | |
headers: {"Cookies": "token=${{secrets.SMR_API_KEY}}", "Content-Type":"application/json"}, | |
body: JSON.stringify({ | |
query: '{getModByReference(modReference:"FicsItNetworks"){versions(filter:{order_by:created_at}){approved}}}' | |
}) | |
}) | |
if (!response.ok) { | |
console.log(`Checking Fetch: Response is not OK: ${response.status}`); | |
} else { | |
const json = await response.json(); | |
let mod = json.data.getModByReference[0]; | |
if (mod.approved && mod.virustotal_results.safe) { | |
console.log("Version got approved!"); | |
return; | |
} | |
console.log("Version not approved yet"); | |
} | |
await new Promise(resolve => setTimeout(resolve, 5000)); | |
} | |
send-discord-release-message: | |
needs: deploy-to-smr | |
uses: ./.github/workflows/send-discord-release.yml | |
secrets: | |
RELEASE_WEBHOOK_URL: ${{ secrets.RELEASE_WEBHOOK_URL }} |