websoft9/.github/workflows/logo.yml
2023-06-08 16:06:50 +08:00

73 lines
2.5 KiB
YAML

name: logo timely update
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
contents: write
steps:
- uses: actions/checkout@master
name: Check out code
- name: delete photo
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "xxx@websoft9.com"
files=$(ls /)
for file in ${files};do
if [ $file == *.png ];then
echo $file
git rm $file
git commit -m "delete"
break
fi
done
git push -u
- name: update logo
if: contains('Hello world', 'abc')
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "xxx@websoft9.com"
# 获取contentful中所有url
entry=$(curl --include \
--request GET \
--header 'Authorization: Bearer ${{secrets.CONTENTFUL_TOKEN}}' \
https://api.contentful.com/spaces/ffrhttfighww/environments/master/entries?content_type=media\&select=fields.slug |tail -n 1)
echo $entry
applist=$(echo $entry | sed 's/en-US/en/g' | jq -r '.items[] | .fields.slug.en')
echo $applist
for app in ${applist};do
if [ "$app" = null ];then
continue
fi
item=$(curl --include \
--request GET \
--header 'Authorization: Bearer ${{secrets.CONTENTFUL_TOKEN}}' \
https://api.contentful.com/spaces/ffrhttfighww/environments/master/entries?content_type=media\&fields.slug=${app}\&select=fields.imageurl\&locale=en-US | tail -n 1)
echo $item
url=$(echo $item | sed 's/en-US/en/' | jq -r '.items[0].fields.imageurl.en')
echo $url
file=$(echo appmanage/static/images/${url##*/})
echo $file
wget --timeout=3 -q "$url" || continue
if [[ -f ${file} ]];then
git rm $file
git commit -m "delete former logo"
fi
wget --no-check-certificate -P appmanage/static/images $url
done
- name: push logo
if: contains('Hello world', 'abc')
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: update logo