Skip to content

archive

archive #1575

Workflow file for this run

name: archive
on:
workflow_run:
workflows:
- build
types:
- completed
jobs:
deploy:
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_repository.full_name == 'Villavu/Simba' && !startsWith(github.event.workflow_run.head_branch, 'dev/')
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
steps:
- name: Download artifacts
uses: actions/github-script@v7
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
for (artifact of allArtifacts.data.artifacts) {
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(artifact.name + '.zip', Buffer.from(download.data));
console.log('Downloaded: ' + artifact.name);
}
- name: Push
shell: bash
env:
BRANCH: ${{ github.event.workflow_run.head_branch }}
SHA: ${{ github.event.workflow_run.head_sha }}
run: |
git config --global http.postBuffer 500M
git config --global user.email "villavu-bot@users.noreply.github.com"
git config --global user.name "villavu-bot"
git clone --depth 1 https://github.com/Villavu/Simba-Build-Archive
echo "Current repo (uncompressed) size:"
du -sh "Simba-Build-Archive" | awk '{print $1}'
date_year=$(date +"%Y")
date_month_day=$(date +"%m-%d")
branch="$BRANCH"
sha="$SHA"
commit=${sha::10}
url="$date_year/$date_month_day%20$branch%20$commit"
raw="https://github.com/Villavu/Simba-Build-Archive/raw/main/$url"
row="$date_year/$date_month_day | $branch | [$commit](https://github.com/Villavu/Simba/commit/$commit) | "
row+="[Win32]($raw/Simba_windows_i386.exe.zip) - "
row+="[Win64]($raw/Simba_windows_x86_64.exe.zip) - "
row+="[Win64&nbsp;Debug]($raw/Simba_windows_x86_64_debug.exe.zip)<br>"
row+="[Mac]($raw/Simba_macos_x86_64.zip) - "
row+="[Mac Arm]($raw/Simba_macos_aarch64.zip)<br>"
row+="[Linux]($raw/Simba_linux_x86_64.zip) - "
row+="[Linux Arm]($raw/Simba_linux_aarch64.zip)"
cd Simba-Build-Archive
dest="$date_year/$date_month_day $branch $commit"
mkdir -p "$dest"
mv ../*.zip "$dest"
# fail (rather than ship dead links) if one is missing.
for f in Simba_windows_i386.exe.zip Simba_windows_x86_64.exe.zip Simba_windows_x86_64_debug.exe.zip \
Simba_macos_x86_64.zip Simba_macos_aarch64.zip Simba_linux_x86_64.zip Simba_linux_aarch64.zip; do
if [ ! -f "$dest/$f" ]; then
echo "::error::Artifact '$f' not found. build.yml artifact names changed?"
exit 1
fi
done
# Insert new row after the 6-line header
sed -i "6r /dev/stdin" README.md <<< "$row"
echo "$raw/Simba_windows_i386.exe.zip" > latest.win32
echo "$raw/Simba_windows_x86_64.exe.zip" > latest.win64
echo "$raw/Simba_linux_x86_64.zip" > latest.linux64
echo "$raw/Simba_linux_aarch64.zip" > latest.linuxarm64
echo "$raw/Simba_macos_x86_64.zip" > latest.macintel
echo "$raw/Simba_macos_aarch64.zip" > latest.macarm64
git add .
git commit --message "$commit"
git push "https://${{ secrets.API_TOKEN_GITHUB }}@github.com/villavu/simba-build-archive"