Skip to content

Update main.yml

Update main.yml #644

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the code branch
push:
branches: [ code ]
pull_request:
branches: [ code ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive --remote
- name: Get twikoo version
id: twikoo
run: |
version=$(curl -s https://raw.githubusercontent.com/Liudon/twikoo-netlify/main/package.json | jq -r '.dependencies."twikoo-netlify"')
echo "Twikoo version: $version"
echo "twikoo_version=$version" >> $GITHUB_OUTPUT
- name: Update config.yml version
uses: fjogeleit/yaml-update-action@main
with:
valueFile: 'config.yml'
propertyPath: 'params.twikoo.version'
value: ${{ steps.twikoo.outputs.twikoo_version }}
commitChange: false
# - name: Compress Image
# run: |
# wget 'https://github.com/kornelski/cavif-rs/releases/download/v1.5.4/cavif-1.5.4.zip'
# unzip cavif-1.5.4.zip
# sudo mv ./linux-generic/cavif /bin
# # find ./content/posts/ -type f \( -name "*.jpg" -o -name "*.png" -o -name "*.jpeg" \) -exec cavif {} \;
- name: Compress Image
run: |
# sudo apt-get update
# sudo apt-get install -y build-essential libx11-dev libxext-dev zlib1g-dev \
# libpng-dev libjpeg-dev libfreetype6-dev libxml2-dev liblcms2-dev \
# libopenexr-dev libtiff-dev libraw-dev libheif-dev libde265-dev \
# libfftw3-dev libglib2.0-dev libwebp-dev
# wget https://download.imagemagick.org/ImageMagick/download/ImageMagick.tar.gz
# tar xvzf ImageMagick.tar.gz
# cd ImageMagick-7.*
# ./configure
# make
# sudo make install
# sudo ldconfig /usr/local/lib
# cd ../
wget 'https://imagemagick.org/archive/binaries/magick'
chmod +x magick
sudo mv magick /usr/local/bin/
magick --version
find ./content/posts/ -type f \( -name "*.jpg" -o -name "*.png" -o -name "*.jpeg" \) -exec magick {} -pointsize 48 -fill "#909090" -font ./static/ArchitectsDaughter-Regular.ttf -gravity south -annotate +0+20 "@liudon\nhttps://liudon.com" -resize 1080x\> {} \;
find ./content/posts/ -type f \( -name "*.jpg" -o -name "*.png" -o -name "*.jpeg" \) -exec magick {} -quality 75 -define webp:image-hint=photo {}_1080x.webp \;
find ./content/posts/ -type f \( -name "*.jpg" -o -name "*.png" -o -name "*.jpeg" \) -exec magick {} {}_1080x.avif \;
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: 'latest'
extended: true
- name: Build
run: |
ls -l ./
hugo --gc --minify --cleanDestinationDir
- name: Push
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.TOKEN }}
publish_branch: master
force_orphan: true
publish_dir: ./public
cname: liudon.com
- name: Easyindex
run: |
echo '${{ secrets.GOOGLE_INDEXING_API_TOKEN }}' > ./credentials.json
touch ./url.csv
echo "\"notification_type\",\"url\"" >> ./url.csv # Headers line
echo "\"URL_UPDATED\",\"https://liudon.com/\"" >> ./url.csv # ADD URL
echo "\"URL_UPDATED\",\"https://liudon.com/sitemap.xml\"" >> ./url.csv # ADD URL
curl -s -L https://github.com/usk81/easyindex-cli/releases/download/v1.0.6/easyindex-cli_1.0.6_linux_amd64.tar.gz | tar xz
chmod +x ./easyindex-cli
./easyindex-cli google -d -c ./url.csv
- name: Generate robots.txt
run: |
echo "User-agent: *" > ./public/robots.txt
echo "Disallow: /" >> ./public/robots.txt
- name: Connect to ssh in BG
timeout-minutes: 2
run: |
echo "${{ secrets.SSHKEY }}" > ../privkey
chmod 600 ../privkey
ssh -o StrictHostKeyChecking=no ${{ secrets.SSHHOST }} -i ../privkey -L 5001:localhost:5001 -fTN
- name: IPFS upload
uses: filebase/ipfs-action@master
id: deploy
timeout-minutes: 2
with:
path: ./public
service: ipfs
verbose: true
host: localhost
port: 5001
protocol: http
key: ipfs-action
- name: IPFS upload to filebase
uses: filebase/ipfs-action@master
with:
path: ./public
service: filebase
pinName: ipfs-action
filebaseBucket: ${{ secrets.FILEBASE_BUCKET }}
filebaseKey: ${{ secrets.FILEBASE_KEY }}
filebaseSecret: ${{ secrets.FILEBASE_SECRET }}
key: ipfs-action