Browse Source

Update self_hosted_patch.yml

Signed-off-by: elseif <elseif@live.cn>
pull/118/head
elseif 9 months ago
committed by GitHub
parent
commit
ef13a0cf68
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 26
      .github/workflows/self_hosted_patch.yml

26
.github/workflows/self_hosted_patch.yml

@ -28,6 +28,11 @@ on:
required: false required: false
default: '' default: ''
type: string type: string
release:
description: "Whether to publish the release"
required: false
default: 'false'
type: boolean
permissions: permissions:
contents: write contents: write
@ -390,7 +395,7 @@ jobs:
- name: Cache refind - name: Cache refind
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && inputs.release == 'true'
id: cache-refind id: cache-refind
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
@ -398,11 +403,11 @@ jobs:
key: refind key: refind
- name: Get refind - name: Get refind
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-refind.outputs.cache-hit != 'true'
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-refind.outputs.cache-hit != 'true' && inputs.release == 'true'
run: sudo wget -nv -O refind-bin-0.14.2.zip https://nchc.dl.sourceforge.net/project/refind/0.14.2/refind-bin-0.14.2.zip run: sudo wget -nv -O refind-bin-0.14.2.zip https://nchc.dl.sourceforge.net/project/refind/0.14.2/refind-bin-0.14.2.zip
- name: Create install-image-${{ env.LATEST_VERSION }}.img - name: Create install-image-${{ env.LATEST_VERSION }}.img
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && inputs.release == 'true'
run: | run: |
sudo modprobe nbd sudo modprobe nbd
sudo apt-get install -y qemu-utils extlinux > /dev/null sudo apt-get install -y qemu-utils extlinux > /dev/null
@ -440,7 +445,7 @@ jobs:
sudo rm ./install-image-$LATEST_VERSION.img sudo rm ./install-image-$LATEST_VERSION.img
- name: Cache NetInstall ${{ env.LATEST_VERSION }} - name: Cache NetInstall ${{ env.LATEST_VERSION }}
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && inputs.release == 'true'
id: cache-netinstall id: cache-netinstall
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
@ -450,13 +455,13 @@ jobs:
key: netinstall-${{ env.LATEST_VERSION }} key: netinstall-${{ env.LATEST_VERSION }}
- name: Get netinstall ${{ env.LATEST_VERSION }} - name: Get netinstall ${{ env.LATEST_VERSION }}
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-netinstall.outputs.cache-hit != 'true'
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-netinstall.outputs.cache-hit != 'true' && inputs.release == 'true'
run: | run: |
sudo wget -nv -O netinstall.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.zip sudo wget -nv -O netinstall.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.zip
sudo wget -nv -O netinstall.tar.gz https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.tar.gz sudo wget -nv -O netinstall.tar.gz https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.tar.gz
- name: Patch netinstall ${{ env.LATEST_VERSION }} - name: Patch netinstall ${{ env.LATEST_VERSION }}
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.get_latest.outputs.has_patched_npk == 'true'
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && inputs.release == 'true'
run: | run: |
sudo unzip netinstall.zip sudo unzip netinstall.zip
sudo -E python3 patch.py netinstall netinstall.exe sudo -E python3 patch.py netinstall netinstall.exe
@ -466,7 +471,7 @@ jobs:
sudo tar -czvf netinstall-$LATEST_VERSION.tar.gz ./netinstall-cli sudo tar -czvf netinstall-$LATEST_VERSION.tar.gz ./netinstall-cli
- name: Upload Files - name: Upload Files
if: steps.get_latest.outputs.has_new_version == 'true'
if: steps.get_latest.outputs.has_new_version == 'true' && inputs.release == 'true'
run: | run: |
sudo mkdir -p ./publish/$LATEST_VERSION sudo mkdir -p ./publish/$LATEST_VERSION
sudo cp CHANGELOG ./publish/$LATEST_VERSION/ sudo cp CHANGELOG ./publish/$LATEST_VERSION/
@ -480,7 +485,7 @@ jobs:
EOF EOF
- name: Clear Cloudflare cache - name: Clear Cloudflare cache
if: steps.get_latest.outputs.has_new_version == 'true'
if: steps.get_latest.outputs.has_new_version == 'true' && inputs.release == 'true'
run: | run: |
curl --request POST --url "https://api.cloudflare.com/client/v4/zones/fe6831ed6dc9e6235e69ef2a31f2e7fe/purge_cache" \ curl --request POST --url "https://api.cloudflare.com/client/v4/zones/fe6831ed6dc9e6235e69ef2a31f2e7fe/purge_cache" \
--header "Authorization: Bearer 9GDQkzU51QXaqzp1qMjyFKpyeJyOdnNoG9GZQaGP" \ --header "Authorization: Bearer 9GDQkzU51QXaqzp1qMjyFKpyeJyOdnNoG9GZQaGP" \
@ -488,7 +493,7 @@ jobs:
--data '{"purge_everything": true}' --data '{"purge_everything": true}'
- name: Delete Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }} - name: Delete Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }}
if: steps.get_latest.outputs.has_new_version == 'true'
if: steps.get_latest.outputs.has_new_version == 'true' && inputs.release == 'true'
run: | run: |
HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}" HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
RELEASE_INFO=$(curl -s -H $HEADER https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION$ARCH) RELEASE_INFO=$(curl -s -H $HEADER https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION$ARCH)
@ -504,7 +509,7 @@ jobs:
fi fi
- name: Create Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }} - name: Create Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }}
if: steps.get_latest.outputs.has_new_version == 'true'
if: steps.get_latest.outputs.has_new_version == 'true' && inputs.release == 'true'
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
name: "RouterOS ${{ env.LATEST_VERSION }} ${{ matrix.arch }}" name: "RouterOS ${{ env.LATEST_VERSION }} ${{ matrix.arch }}"
@ -521,6 +526,7 @@ jobs:
all_packages-*-${{ env.LATEST_VERSION }}.zip all_packages-*-${{ env.LATEST_VERSION }}.zip
- name: Create Packages CSV File - name: Create Packages CSV File
if: inputs.release == 'true'
run: | run: |
sudo apt-get install ssh sshpass sudo apt-get install ssh sshpass
sshpass -p "${{ secrets.SSH_PASSWORD }}" ssh -o StrictHostKeyChecking=no -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_SERVER }} "echo $LATEST_VERSION $BUILD_TIME | tee /rw/disk/${{ secrets.SSH_DIRECTORY }}/NEWESTa7.${{ matrix.channel }}; /rw/disk/${{ secrets.SSH_DIRECTORY }}/packages.sh /rw/disk/${{ secrets.SSH_DIRECTORY }}/$LATEST_VERSION" sshpass -p "${{ secrets.SSH_PASSWORD }}" ssh -o StrictHostKeyChecking=no -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_SERVER }} "echo $LATEST_VERSION $BUILD_TIME | tee /rw/disk/${{ secrets.SSH_DIRECTORY }}/NEWESTa7.${{ matrix.channel }}; /rw/disk/${{ secrets.SSH_DIRECTORY }}/packages.sh /rw/disk/${{ secrets.SSH_DIRECTORY }}/$LATEST_VERSION"

Loading…
Cancel
Save