sync_wireproxy.yml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. name: Synchronize wireproxy
  2. on:
  3. workflow_dispatch:
  4. schedule:
  5. - cron: '13 2 * * *'
  6. jobs:
  7. build:
  8. name: Synchronize wireproxy
  9. runs-on: ubuntu-latest
  10. env:
  11. FILE_DIR: wireproxy
  12. steps:
  13. - uses: actions/[email protected]
  14. - name: Synchronize wireproxy to the latest version
  15. run: |
  16. NOW=$(wget -qO- https://raw.githubusercontent.com/${{ github.repository }}/main/wireproxy/version_history | head -n 1 | sed "s/.*v\(.*\)/\1/g")
  17. LATEST=$(wget -qO- "https://api.github.com/repos/octeep/wireproxy/releases/latest" | grep "tag_name" | head -n 1 | cut -d : -f2 | sed 's/[ \"v,]//g')
  18. if [ "$LATEST" != "$NOW" ]; then
  19. [ ! -d ${{ env.FILE_DIR }} ] && mkdir -p ${{ env.FILE_DIR }}
  20. PLATFORM=( "linux_amd64" "linux_arm64" "linux_s390x" )
  21. for i in "${PLATFORM[@]}"; do
  22. wget -O ${{ env.FILE_DIR }}/wireproxy_"$i".tar.gz https://github.com/octeep/wireproxy/releases/download/v"$LATEST"/wireproxy_"$i".tar.gz
  23. done
  24. sed -i "1i$(date "+%Y/%m/%d") v$LATEST" ${{ env.FILE_DIR }}/version_history || true
  25. echo "VERSION=$LATEST" >> $GITHUB_ENV
  26. echo "DATE=$(date "+%Y/%m/%d %H:%M:%S")" >> $GITHUB_ENV
  27. fi
  28. - name: Upload to repository
  29. uses: stefanzweifel/[email protected]
  30. if: ${{ env.VERSION != '' }}
  31. with:
  32. commit_message: Sync wireproxy to V${{ env.VERSION }} by Github Actions, ${{ env.DATE }}