-
错误信息类似
我把成功和失败的网站favicon下载下来用trid确认了一下,某个打包成功的网站我以为是png的巨型图标实际是ico格式,失败网站用的png格式的favicon。 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
等等,我问下ChatGPT能不能帮我写个Github Action…… name: Download and Convert Icon
on:
workflow_dispatch:
inputs:
domain:
description: 'Enter the domain name or URL to download the icon'
required: true
jobs:
download-convert-icon:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Extract domain name from URL
run: echo "DOMAINNAME=$(echo "${{ github.event.inputs.domain }}" | tr '[:upper:]' '[:lower:]' | awk -F[/:] '{ if ($1 == "http" || $1 == "https" || $1 == "ftp") { print $4 } else { print $1 } }' )" >> $GITHUB_ENV
- name: Install ImageMagick
run: sudo apt-get install -y imagemagick
- name: Download icon
run: curl -o "input/${{env.DOMAINNAME}}.ico" "https://icons.duckduckgo.com/ip3/${{env.DOMAINNAME}}.ico"
- name: Identify file format
run: |
FILEFORMAT=$(identify -format '%m' input/${{env.DOMAINNAME}}.ico)
echo "FILEFORMAT=${FILEFORMAT:0:3}" >> $GITHUB_ENV
- name: Move ICO file to directory
if: ${{ env.FILEFORMAT == 'ICO' }}
run: mv "input/${{env.DOMAINNAME}}.ico" "ico/${{env.DOMAINNAME}}.ico"
- name: Convert to ICO
if: ${{ env.FILEFORMAT == 'PNG' || env.FILEFORMAT == 'JPE' }}
run: convert -background transparent "input/${{env.DOMAINNAME}}.ico" -define icon:auto-resize=16,24,32,48,64,72,96,128,256 "ico/${{env.DOMAINNAME}}.ico"
- name: Extract branch name
run: echo "CURRBRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Check output file, update list and cleanup
run: |
if test -f "ico/${{env.DOMAINNAME}}.ico" ; then
if test -f "ico/list.md" ; then
mv ico/list.md ico/listtmp.md
fi
echo "- https://raw.githubusercontent.com/${{github.repository}}/${{env.CURRBRANCH}}/ico/${{env.DOMAINNAME}}.ico" >> ico/listtmp.md
sort ico/listtmp.md | uniq >> ico/list.md
rm -f input/${{env.DOMAINNAME}}.ico
rm -f ico/listtmp.md
fi
- name: update repo
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git add ico/list.md
git add ico/${{env.DOMAINNAME}}.ico
git commit -m "Add ${{env.DOMAINNAME}}.ico" || :
git push || : 第一次写Github Action不会写纯乱搞,踩了一堆坑
|
Beta Was this translation helpful? Give feedback.
-
可以将这个图标放github,然后你就有一个链接了 |
Beta Was this translation helpful? Give feedback.
目前是用imagemagick的convert转成ico,然后扔到克隆出来的Pake项目的ico目录下,拿github当网盘D:\tools\ImageMagick\convert.exe -background transparent "deepl.png" -define icon:auto-resize=16,24,32,48,64,72,96,128,256 "D:\tools\Pake\ico\deepl.ico"
等等,我问下ChatGPT能不能帮我写个Github Action……
大致就是下面这样了,创建
input
和ico
两个目录 → 往工作流里投喂域名或url → 到ico/list.md
收取图标地址甚至可以命令行操作