Skip to content

Custom WSA Build Do not edit this #2767

Custom WSA Build Do not edit this

Custom WSA Build Do not edit this #2767

name: Auto comment Issues
on:
issues:
types: [opened, reopened]
issue_comment:
types: [created, edited, deleted]
jobs:
build:
if: github.event_name == 'issues'
name: Build WSA and Check comment
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create Issues comment
id: comment
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: |
We are checking your Issues body and head ...
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
----
emoji: heart
- name: Setup Python
uses: actions/setup-python@v5
with:
check-latest: true
python-version: '3.10'
cache: 'pip'
cache-dependency-path: scripts/
- name: Update Package
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo apt-get update
python3 -m pip install --upgrade setuptools
- name: Get Issues Info
id: get-issues
uses: actions/github-script@v7
with:
script: |
var fs = require('fs');
var issuenumber = ${{ toJSON(github.event.issue.number) }};
var issueauth = ${{ toJSON(github.event.issue.user.login) }};
var issuetitle = ${{ toJSON(github.event.issue.title) }};
var issuebody = ${{ toJSON(github.event.issue.body) }};
if (issuetitle != null) {
issuetitle = issuetitle.replace(/\u000A|\u000D/g, ""); //Replace newline letter
}
if (issuebody != null) {
issuebody = issuebody.replace(/\u0008|\u0009|\u000A|\u000B|\u000C|\u000D|\u00A0|\u2028|\u2029|\uFEFF/g, "");
issuebody = issuebody.replace(/—/g, "-");
}
core.setOutput("issuenumber", JSON.stringify(issuenumber));
core.setOutput("issueauth", JSON.stringify(issueauth));
core.setOutput("issuetitle", JSON.stringify(issuetitle));
core.setOutput("issuebody", JSON.stringify(issuebody));
- name: Set Issues Info
if: success()
run: |
echo "issuenumber="${{ steps.get-issues.outputs.issuenumber }}"" >> $GITHUB_ENV
echo "issueauth="${{ steps.get-issues.outputs.issueauth }}"" >> $GITHUB_ENV
echo "issuetitle="${{ steps.get-issues.outputs.issuetitle }}"" >> $GITHUB_ENV
echo "issuebody="${{ steps.get-issues.outputs.issuebody }}"" >> $GITHUB_ENV
- name: Get Build Info
shell: python
run: |
import os, re, json, shutil, string, subprocess
def set_output(name, value):
subprocess.call(["echo '{}={}' >> $GITHUB_ENV".format(name, value)], shell=True)
if __name__ == '__main__':
issues = 'false'
ismagisk = 'false'
iscustom = 'true'
errinfo = body = ''
try:
if '${{ env.issuetitle }}'.lower().startswith('custom wsa build'):
issues = 'true'
body = '${{ env.issuebody }}'
else:
iscustom = 'false'
if re.match(".*arch.*64.*release-type.*root-sol.*magisk-branch.*magisk-ver.*compress-format.*", body):
iscustom = 'true'
else:
iscustom = 'false'
errinfo = 'Argument is invaild, please update the body of the Issues'
if re.match(".*arch.*64.*release-type.*root-sol\smagisk.*magisk-branch.*magisk-ver.*compress-format.*", body):
ismagisk = 'true'
except Exception as e:
iscustom = 'false'
errinfo = 'Issues Body error, {}.'.format(e)
set_output('issues', issues)
set_output('iscustom', iscustom)
set_output('ismagisk', ismagisk)
set_output('errinfo', errinfo)
set_output('body', body)
- name: Add Issues labels
if: env.issues == 'true' && env.iscustom == 'true'
uses: actions-cool/issues-helper@v3
with:
actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ env.issuenumber }}
labels: 'custom'
- name: Update Comment Begin
if: env.issues == 'true' && env.iscustom == 'true'
uses: actions-cool/issues-helper@v3
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.comment.outputs.comment-id }}
update-mode: replace
body: |
Hello ${{ env.issueauth }} .
Your custom WSA build has started building. Please go to the URL below for more details.
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
----
emoji: heart
- name: Update Comment Error
if: env.issues == 'true' && env.iscustom == 'false'
uses: actions-cool/issues-helper@v3
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.comment.outputs.comment-id }}
update-mode: replace
body: |
Hello ${{ env.issueauth }}.
Look like we have a problem with the workflow. We will take a look soon.
`Error Info:`
`${{ env.errinfo }}`
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
----
emoji: eyes
- name: Update Comment Invalid
if: env.issues == 'false'
uses: actions-cool/issues-helper@v3
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.comment.outputs.comment-id }}
update-mode: replace
body: |
Hello ${{ env.issueauth }}.
Thanks for sending an issues. Now our admin is inactive, just waiting and he will reply you soon.
Hope you have a nice day.
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
----
emoji: eyes
- name: Install Ubuntu Dependencies
if: env.iscustom == 'true' && success()
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: e2fsprogs attr unzip qemu-utils python3-venv
version: 1.0
- name: Setup Python3 Virtual Enviroment
if: env.iscustom == 'true' && success()
working-directory: scripts
run: |
PYTHON_VENV_DIR="$(dirname "$PWD")/python3-env"
python3 -m venv "$PYTHON_VENV_DIR" || abort "Failed to create python3 virtual env"
# shellcheck disable=SC1091
source "$PYTHON_VENV_DIR/bin/activate" || abort "Failed to activate python3 virtual env"
python3 -c "import pkg_resources; pkg_resources.require(open('requirements.txt',mode='r'))" &>/dev/null || {
echo "Installing Python3 dependencies"
python3 -m pip install --upgrade -r requirements.txt || abort "Failed to install python3 dependencies"
}
deactivate
- name: Build WSA
id: wsa
if: env.iscustom == 'true' && success()
run: |
mkdir -p download
if [[ ${{ env.ismagisk }} == 'true' ]]; then
./scripts/build_with_lspinit.sh ${{ env.body }}
else
./scripts/build_with_mount.sh ${{ env.body }}
fi
- name: Pass to Windows
if: env.iscustom == 'true' && success()
uses: actions/cache/save@v4
with:
path: output
key: ${{ steps.wsa.outputs.artifact }}-${{ steps.wsa.outputs.built }}
enableCrossOsArchive: true
outputs:
artifact: ${{ steps.wsa.outputs.artifact }}
file_ext: ${{ steps.wsa.outputs.file_ext }}
arch: ${{ steps.wsa.outputs.arch }}
built: ${{ steps.wsa.outputs.built }}
comment-id: ${{ steps.comment.outputs.comment-id }}
iscustom: ${{ env.iscustom }}
make-pri:
if: needs.build.outputs.iscustom == 'true'
name: Merge PRI resources and Complete issue
runs-on: windows-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download built artifact
uses: actions/cache/restore@v4
with:
path: output
key: ${{ needs.build.outputs.artifact }}-${{ needs.build.outputs.built }}
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: Merge language and density resources
if: success()
run: |
if ("${{ needs.build.outputs.arch }}" -eq "x64") {
(Start-Process pwsh.exe -NoNewWindow -PassThru -Args "-ExecutionPolicy Bypass -File MakePri.ps1" -WorkingDirectory "${{ github.workspace }}\output\${{ needs.build.outputs.artifact }}").WaitForExit()
} else {
Copy-Item -Force "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\arm64\makepri.exe" "${{ github.workspace }}\output\${{ needs.build.outputs.artifact }}"
}
- name: Compact Images 💿
if: success()
run: |
foreach ($Partition in 'system','product','system_ext','vendor') {
Write-Output "Optimizing of $Partition..."
Write-Output "SELECT VDISK FILE=`"${{ github.workspace }}\output\${{ needs.build.outputs.artifact }}\$Partition.vhdx`"`
ATTACH VDISK READONLY`
COMPACT VDISK`
DETACH VDISK" | Set-Content -Path "$Partition.txt" -Encoding Ascii
Start-Process -NoNewWindow -Wait "diskpart.exe" -Args "/s $Partition.txt" -RedirectStandardOutput NUL
}
- name: Compress 7-Zip and Add checksum
if: success() && needs.build.outputs.file_ext == '7z'
working-directory: output
run: |
7z a -t7z -mx=6 -m0=LZMA2 -ms=on -mmt=8 -sdel -- "${{ needs.build.outputs.artifact }}.7z" "${{ needs.build.outputs.artifact }}\*"
($(Get-FileHash -Path "${{ needs.build.outputs.artifact }}.7z" -Algorithm SHA256).Hash.ToLower().ToString() + " " + "${{ needs.build.outputs.artifact }}.7z") | Out-File -FilePath sha256-checksum.txt -Encoding UTF8
- name: Upload to Artifacts
if: success()
uses: actions/upload-artifact@v4
with:
name: ${{ needs.build.outputs.artifact }}-built
path: output
retention-days: 5
- name: Update Comment Finish
if: success()
uses: actions-cool/issues-helper@v3
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ needs.build.outputs.comment-id }}
update-mode: replace
body: |
Hello ${{ env.issueauth }}.
Your custom WSA build has been built. Please go to the URL below to download it.
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
----
PS:
When you downloaded your build, please comment "delete builds" to delete the build and log.
Thank you and hope you have a nice day !
>
----
emoji: hooray
- name: Close Issues
if: success()
uses: actions-cool/issues-helper@v3
with:
actions: 'close-issue'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ env.issuenumber }}
- name: Update Comment Fail
if: failure()
uses: actions-cool/issues-helper@v3
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ needs.build.outputs.comment-id }}
update-mode: replace
body: |
Hello ${{ env.issueauth }}.
Your custom WSA build failed to build. Don't worry! Our admin will take a look soon.
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
----
emoji: confused
delete_builds:
name: Delete build action
runs-on: ubuntu-latest
if: github.event_name == 'issue_comment' && contains('delete builds', github.event.comment.body)
steps:
- name: Find bots comments
id: find-bots
uses: actions-cool/issues-helper@v3
with:
actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
comment-auth: 'github-actions[bot]'
- name: Find runs comments
id: find-runs
uses: actions-cool/issues-helper@v3
with:
actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
comment-auth: 'github-actions[bot]'
body-includes: '${{ github.server_url }}/${{ github.repository }}/actions/runs'
- name: Delete build Data
id: delete-build
uses: actions/github-script@v7
with:
script: |
async function main() {
var botscomments = ${{ steps.find-bots.outputs.comments }};
console.log("botscomments: " + botscomments);
var runscomments = ${{ steps.find-runs.outputs.comments }};
console.log("runscomments: " + runscomments);
var botids = [];
for (i = 0; i < botscomments.length; i++) {
botids.push(botscomments.at(i)["id"]);
}
console.log("botids: " + botids);
var runids = [];
for (i = 0; i < runscomments.length; i++) {
bodylines = runscomments.at(i)["body"].split("\n")
for (j = 0; j < bodylines.length; j++) {
if (bodylines.at(j).indexOf("runs/") != -1) {
let runid = bodylines.at(j).substring(bodylines.at(j).lastIndexOf('/') + 1).replace(/^\s+|\s+$/g, '');
runids.push({"id": runscomments.at(i)["id"], "runid": runid});
}
}
}
console.log("runids: " + runids);
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
if (runids.length > 0) {
var deleted = [];
for (index = 0; index < runids.length; index++) {
try {
if (false == deleted.includes(runids.at(index)["runid"])) {
const dellogs = await github.rest.actions.deleteWorkflowRunLogs({
owner,
repo,
run_id: runids.at(index)["runid"],
});
console.log("DELETE logs: %s", dellogs);
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id: runids.at(index)["runid"],
per_page: 100,
});
console.log("artifacts: %s", artifacts.data);
for (const artifact of artifacts.data.artifacts) {
console.log(`artifact id ${artifact.id} of ${artifact.name}`)
const delartifacts = await github.rest.actions.deleteArtifact({
owner,
repo,
artifact_id: artifact.id,
});
console.log(`DELETE artifacts(${artifact.id}): ${delartifacts}`)
}
deleted.push(runids.at(index)["runid"]);
}
} catch (error) {
core.setFailed(error.message);
}
}
}
if (botids.length > 0) {
for (index = 0; index < botids.length; index++) {
try {
const retcomments = await github.rest.issues.updateComment({
owner,
repo,
comment_id: botids.at(index),
body: '`deleted`'
})
console.log("PATCH emoji: %s", retcomments);
} catch (error) {
core.setFailed(error.message);
}
}
}
}
main();
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}