0
0
mirror of https://github.com/TrianguloY/UrlChecker.git synced 2024-09-20 04:12:14 +02:00

fixed (and tweaked) assets updater action

Fix:
- the clearURL url was using the non-minified one

Improvements:
- allow to run manually
- more detailed descriptions for commits and the PR
This commit is contained in:
TrianguloY 2022-10-09 11:00:11 +02:00
parent fe2d633892
commit 159e185068

View File

@ -4,28 +4,32 @@ name: Assets updater
on: on:
# weekly # weekly
schedule: schedule:
- cron: '0 0 * * Sun' - cron: '0 0 * * SUN'
# manually
workflow_dispatch:
permissions: permissions:
contents: write contents: write
pull-requests: write pull-requests: write
jobs:
download:
runs-on: ubuntu-latest
env: env:
workingBranch: assets-updater-action workingBranch: assets-updater-action
jobs:
update:
runs-on: ubuntu-latest
steps: steps:
- name: Checkout main - name: Checkout main
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Git config - name: Git config
run: | run: |
git config user.name 'github-actions[bot]' git config user.name 'github-actions'
git config user.email 'github-actions[bot]@users.noreply.github.com' git config user.email 'github-actions@github.com'
- name: Check if branch exists - name: Prepare branch
run: | run: |
count=($(git ls-remote --heads origin "$workingBranch" | wc)) count=($(git ls-remote --heads origin "$workingBranch" | wc))
if [[ ${count[0]} -ne 0 ]]; then if [[ ${count[0]} -ne 0 ]]; then
@ -39,22 +43,32 @@ jobs:
fi fi
- name: ClearURLs catalog - name: ClearURLs catalog
continue-on-error: true continue-on-error: true # just skip the file
run: | run: |
bash ./.github/scripts/file-updater.sh $fileName $fileURL $filePath $hashURL bash ./.github/scripts/file-updater.sh $fileName $fileURL $filePath $hashURL
git add "$filePath$fileName" git add "$filePath$fileName"
git commit -m "$message" git commit -m "
$message
File: $filePath$fileName
Url: $fileURL
Hash: $hashURL
"
git push git push
echo "$fileName commited successfully" echo "$fileName commited successfully"
env: env:
fileName: "data.minify.json" fileName: "data.minify.json"
fileURL: "https://rules2.clearurls.xyz/data.min.json" fileURL: "https://rules2.clearurls.xyz/data.minify.json"
filePath: "./app/src/main/assets/" filePath: "./app/src/main/assets/"
hashURL: "https://rules2.clearurls.xyz/rules.min.hash" hashURL: "https://rules2.clearurls.xyz/rules.minify.hash"
message: "ClearURLs catalog updated" message: "ClearURLs catalog updated"
- name: Pull request - name: Pull request
run: continue-on-error: true # ignore if the pr already exists
gh pr create --title 'Automated assets updater action' --body '' run: |
gh pr create --title 'Assets updated (automatic action)' --body 'One or more assets were updated.
This is an automatic PR run from a [github action](../actions/workflows/assets-updater.yml)'
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}