Skip to content

v4.73.4

v4.73.4 #416

Workflow file for this run

name: Generate File
on:
push:
branches:
- main
paths-ignore:
- '**.md' # Ignore markdown files changes to trigger this workflow
- '**.gitignore'
- 'LICENSE'
jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2 # Fetch only the last 2 commits to check for changes in version.ini
- name: Cache files
uses: actions/cache@v3
with:
path: |
./version.ini
./js/content.js
./userscript/template.js
key: files-key-${{ hashFiles('./version.ini', './js/content.js', './userscript/template.js') }}
- name: Read version
run: echo "VERSION=$(cat version.ini)" >> $GITHUB_ENV
- name: Check if version has changed
id: version-check
run: |
git diff --exit-code --quiet HEAD..HEAD^ version.ini || echo "HAS_CHANGED=true" >> $GITHUB_ENV
- name: Create directory
run: mkdir -p generated
- name: Remove comment and Generate file
if: env.HAS_CHANGED == 'true'
run: |
version="${{ env.VERSION }}"
commit_sha=$(git rev-parse HEAD)
commit_desc="$(git log -1 --pretty=%B | sed '1d' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
content_r=$(perl -0777 -pe 's|\s*\/\*[^\*]*(?:(?!\*\/)\*[^\*]*)*\*\/\s*||' js/content.js)
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout -B generated-files origin/main
echo "$content_r" > temp_content.js
cp userscript/template.js temp_template.js
sed -i "s/{{VERSION}}/$version/g; s/{{COMMIT_SHA}}/$commit_sha/g" temp_template.js
sed -i '/{{CONTENT}}/r temp_content.js' temp_template.js
sed -i '/{{CONTENT}}/d' temp_template.js
rm temp_content.js
mv -f temp_template.js generated/Tabview-Youtube.user.js
git add generated/Tabview-Youtube.user.js
if ! git diff --exit-code --quiet --cached; then
git commit -m "UserJS (v$version) | $commit_sha" -m "$commit_desc"
git push -f origin generated-files
fi