diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml index fa4d2bb6..a730b1b3 100644 --- a/.github/workflows/issues.yml +++ b/.github/workflows/issues.yml @@ -14,6 +14,9 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@main + - name: Init Env run: | git config --global user.email "github-actions[bot]@users.noreply.github.com" @@ -21,15 +24,37 @@ jobs: sudo timedatectl set-timezone "Asia/Shanghai" - name: Check Issues + shell: python run: | - if echo "${{ github.event.issue.body }}" | grep -q "ENV"; then - echo "FALG=true" >> $GITHUB_ENV - else - echo "FALG=false" >> $GITHUB_ENV - fi + # -*- coding: utf-8 -*- + import json, subprocess + def set_output(name, value): + subprocess.call(["echo '{}={}' >> $GITHUB_ENV".format(name, value)], shell=True) - - name: Create Issues comment - if: env.FALG == 'false' + issuetitle = ${{ toJSON(github.event.issue.title) }}; + issuebody = ${{ toJSON(github.event.issue.body) }}; + + iscustom = 'false' + warinfo = 'false' + model = '' + try: + if issuetitle.lower().startswith('custom'): + json_object = json.loads(issuebody) + iscustom = 'true' + model = json_object.get('model', '') + except ValueError as e: + pass + + if iscustom == 'false': + if issuebody.find('ENV') >= 0: + warinfo = 'true' + + set_output("iscustom", iscustom) + set_output("warinfo", warinfo) + set_output("model", model) + + - name: Update Comment Warinfo + if: env.warinfo == 'true' uses: actions-cool/issues-helper@v3 with: actions: "create-comment" @@ -68,3 +93,118 @@ jobs: ... If you can't provide detailed information, then wait for someone who is destined! emoji: heart + + - name: Update Comment Labels + if: env.iscustom == 'true' + uses: actions-cool/issues-helper@v3 + with: + actions: 'add-labels' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + labels: 'custom,${{ env.model }}' + + - name: Update Comment Building + if: env.iscustom == 'true' + id: comment + uses: actions-cool/issues-helper@v3 + with: + actions: 'create-comment' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + Hi @${{ github.event.issue.user.login }}. + RR-${{ env.model }} is being build and package and will be sent to your email later.. + > ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + ---- + emoji: heart + + - name: Run Build + if: env.iscustom == 'true' + run: | + # 累了, 毁灭吧 + + REPO=${{ github.server_url }}/${{ github.repository }} + MODEL=${{ env.model }} + PRERELEASE="false" + + TAG="" + if [ "${PRERELEASE}" = "true" ]; then + TAG="$(curl -skL --connect-timeout 10 "${REPO}/tags" | grep /refs/tags/.*\.zip | head -1 | sed -r 's/.*\/refs\/tags\/(.*)\.zip.*$/\1/')" + else + LATESTURL="$(curl -skL --connect-timeout 10 -w %{url_effective} -o /dev/null "${REPO}/releases/latest")" + TAG="${LATESTURL##*/}" + fi + [ "${TAG:0:1}" = "v" ] && TAG="${TAG:1}" + rm -f rr-${TAG}.img.zip + STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${REPO}/releases/download/${TAG}/rr-${TAG}.img.zip" -o "rr-${TAG}.img.zip") + if [ $? -ne 0 -o ${STATUS:-0} -ne 200 ]; then + echo "Download failed" + exit 1 + fi + + unzip rr-${TAG}.img.zip -d "rr" + + export TERM=xterm + + sudo ./localbuild.sh init rr rr/rr.img + sudo ./localbuild.sh config ${MODEL} + sudo ./localbuild.sh pack rr/rr.img + + ls rr -al + zip -9 "rr-${MODEL}-${TAG}-${{ github.run_id }}.img.zip" -j rr/rr.img + + UPLOAD="$(curl -k -F "file=@rr-${MODEL}-${TAG}-${{ github.run_id }}.img.zip" -F "token=${{ secrets.TT_TOKEN }}" -F "model=0" -X POST "https://tmp-cli.vx-cdn.com/app/upload_cli")" + if ! echo "${UPLOAD}" | grep -q "Download Page"; then + echo "Upload failed" + exit 1 + fi + + EMAIL=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/users/${{ github.event.issue.user.login }}" | jq -r '.email') + TTDLURL="$(echo "${UPLOAD}" | grep "Download Page" | head -1)" + echo "TAG=${TAG}" >> $GITHUB_ENV + echo "EMAIL=${EMAIL}" >> $GITHUB_ENV + echo "TTDLURL=${TTDLURL}" >> $GITHUB_ENV + + - name: Send mail + if: env.iscustom == 'true' && success() + uses: dawidd6/action-send-mail@v3 + with: + server_address: smtp-mail.outlook.com + server_port: 587 + username: ${{ secrets.MAIL_USERNAME }} + password: ${{ secrets.MAIL_PASSWORD }} + subject: rr-${{ env.model }}-${{ env.TAG }} + to: ${{ env.EMAIL }} + from: ${{ secrets.MAIL_USERNAME }} + body: | + ${{ env.TTDLURL }} + + - name: Update Comment Success + if: env.iscustom == 'true' && success() + 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: | + Hi @${{ github.event.issue.user.login }}. + RR-${{ env.model }} has been sent to your email. + > ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + ---- + emoji: hooray + + - name: Update Comment Fail + if: env.iscustom == 'true' && failure() + 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: | + Hi @${{ github.event.issue.user.login }}. + RR-${{ env.model }} failed to build and package, please try again. + > ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + ---- + emoji: confused \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 64ea13aa..be1c0deb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,6 +1,6 @@
- + \ No newline at end of file diff --git a/docs/issues.html b/docs/issues.html new file mode 100644 index 00000000..7728cfec --- /dev/null +++ b/docs/issues.html @@ -0,0 +1,210 @@ + + + + + + + + + + + + + + + + + + + + + + + ++██████╗ ██████╗ ██████╗██╗ ██╗███████╗████████╗ ██████╗ ███╗ ███╗ +██╔══██╗██╔══██╗ ██╔════╝██║ ██║██╔════╝╚══██╔══╝██╔═══██╗████╗ ████║ +██████╔╝██████╔╝█████╗██║ ██║ ██║███████╗ ██║ ██║ ██║██╔████╔██║ +██╔══██╗██╔══██╗╚════╝██║ ██║ ██║╚════██║ ██║ ██║ ██║██║╚██╔╝██║ +██║ ██║██║ ██║ ╚██████╗╚██████╔╝███████║ ██║ ╚██████╔╝██║ ╚═╝ ██║ +╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ + ++