Skip to content

Commit

Permalink
Create GitHub action to automatically update images in PRs (#39)
Browse files Browse the repository at this point in the history
* adds action to convert images in PRs

* Generated image files

* Apply suggestions from code review

Co-authored-by: Marc Neudert <[email protected]>

---------

Co-authored-by: innocraft-automation <[email protected]>
Co-authored-by: Marc Neudert <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent 9a429a1 commit 1745845
Show file tree
Hide file tree
Showing 613 changed files with 145 additions and 4 deletions.
141 changes: 141 additions & 0 deletions .github/workflows/convertimages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Convert Images

on:
pull_request:
types: [opened, synchronize]

permissions:
actions: read
checks: read
contents: write
deployments: none
issues: read
packages: none
pull-requests: write
repository-projects: none
security-events: none
statuses: none

jobs:
build:
runs-on: 'ubuntu-22.04'
name: Convert Images
steps:
- name: Detect branch for PR
id: vars
run: |
PR="${{ github.event.pull_request.number }}"
PR_INFO=$( curl \
--request GET \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--url https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/$PR )
REF=$(echo "${PR_INFO}" | jq -r .head.ref)
BASE=$(echo "${PR_INFO}" | jq -r .head.repo.full_name)
STATE=$(echo "${PR_INFO}" | jq -r .state)
BASE_SHA=$(echo "${PR_INFO}" | jq -r .base.sha)
if [[ $STATE == "closed" ]]
then
echo "Pull Request already closed."
exit 0;
fi
echo "islocalbranch=$(expr $BASE == $GITHUB_REPOSITORY)" >> $GITHUB_OUTPUT
echo "branch=$REF" >> $GITHUB_OUTPUT
echo "base=$BASE_SHA" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
if: steps.vars.outputs.branch != ''
- name: Check images changes
id: imagecheck
run: |
git fetch --depth=1 origin ${{ steps.vars.outputs.base }}
IMAGES_MODIFIED=$(git diff --name-only ${{ steps.vars.outputs.base }} -- src/ .github/workflows/convertimages.yml | wc -l)
if [[ $IMAGES_MODIFIED == "0" ]]
then
echo "No images modified"
exit 0;
fi
echo "images_modified=1" >> $GITHUB_OUTPUT
if: steps.vars.outputs.branch != ''
- name: Install Dependencies
run: |
npm install
sudo apt-get update
git clone --recursive --branch 3.0.3 https://github.com/kornelski/pngquant.git
cd pngquant
cargo build --release
sudo cp target/release/pngquant /usr/local/bin/
cd ..
pngquant --version
sudo add-apt-repository universe
sudo add-apt-repository ppa:inkscape.dev/stable
sudo apt-get update
sudo apt-get install inkscape
sudo apt-get install imagemagick
shell: bash
if: steps.vars.outputs.branch != '' && steps.imagecheck.outputs.images_modified == '1'
- name: Prepare git config
run: |
cat <<- EOF > $HOME/.netrc
machine github.com
login innocraft-automation
password $CUSTOM_ACCESS_TOKEN
machine api.github.com
login innocraft-automation
password $CUSTOM_ACCESS_TOKEN
EOF
chmod 600 $HOME/.netrc
git config --global user.email "[email protected]"
git config --global user.name "innocraft-automation"
git remote set-url origin https://x-access-token:${{ secrets.CUSTOM_ACCESS_TOKEN }}@github.com/$GITHUB_REPOSITORY
if [[ ${{ steps.vars.outputs.islocalbranch }} ]]
then
git fetch --depth=1 origin $BRANCH_NAME
git checkout $BRANCH_NAME
fi
env:
BRANCH_NAME: ${{ steps.vars.outputs.branch }}
if: steps.vars.outputs.branch != '' && steps.imagecheck.outputs.images_modified == '1'
- name: Run convert images
run: ./convert.sh
shell: bash
if: steps.vars.outputs.branch != '' && steps.imagecheck.outputs.images_modified == '1'
- name: Push changes
id: push
run: |
if [[ $( git diff --numstat dist ) ]]
then
if [[ ! ${{ steps.vars.outputs.islocalbranch }} ]]
then
echo "It's only possible to update local branches automatically. Adding a comment instead."
echo "failure=1" >> $GITHUB_OUTPUT
else
cd $GITHUB_WORKSPACE
git add dist/ versions.txt
git commit -m "Generated image files"
git push
fi
fi
if: steps.vars.outputs.branch != '' && steps.imagecheck.outputs.images_modified == '1'
- uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Image files are not up to date. Please generate them locally and push them to your branch.'
})
if: steps.push.outputs.failure == '1'
- name: Fail if not up to date
run: exit 1
if: steps.push.outputs.failure == '1'
Binary file modified dist/SEO/alexa.com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/SEO/bing.com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/SEO/google.com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/SEO/whois.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/3Q.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/4Good.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/AGM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Ace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Acer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Advan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Advance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Aiwa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Alcatel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Amazon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Apple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Archos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Asus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Audiovox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Avvio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Azumi_Mobile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/BBK.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/BGH.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/BangOlufsen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Barnes_Noble.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Becker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dist/brand/Beeline.png
Binary file modified dist/brand/Beetel.png
Binary file modified dist/brand/BenQ.png
Binary file modified dist/brand/Bitel.png
Binary file modified dist/brand/Blaupunkt.png
Binary file modified dist/brand/Bluboo.png
Binary file modified dist/brand/China Mobile.png
Binary file modified dist/brand/Clarmin.png
Binary file modified dist/brand/ComTrade_Tesla.png
Binary file modified dist/brand/Comio.png
Binary file modified dist/brand/Compal.png
Binary file modified dist/brand/Compaq.png
Binary file modified dist/brand/Crosscall.png
Binary file modified dist/brand/Cyrus.png
Binary file modified dist/brand/DEXP.png
Binary file modified dist/brand/Danew.png
Binary file modified dist/brand/Dell.png
Binary file modified dist/brand/Dialog.png
Binary file modified dist/brand/Digi.png
Binary file modified dist/brand/Digicel.png
Binary file modified dist/brand/Digma.png
Binary file modified dist/brand/Doro.png
Binary file modified dist/brand/EE.png
Binary file modified dist/brand/EKO.png
Binary file modified dist/brand/Echo_Mobiles.png
Binary file modified dist/brand/Energizer.png
Binary file modified dist/brand/Ericsson.png
Binary file modified dist/brand/Essential.png
Binary file modified dist/brand/Essentielb.png
Binary file modified dist/brand/Evolveo.png
Binary file modified dist/brand/FNB.png
Binary file modified dist/brand/Fairphone.png
Binary file modified dist/brand/FiGO.png
Binary file modified dist/brand/Freetel.png
Binary file modified dist/brand/Fujitsu.png
Binary file modified dist/brand/General_Mobile.png
Binary file modified dist/brand/Ghia.png
Binary file modified dist/brand/GoMobile.png
Binary file modified dist/brand/Google.png
Binary file modified dist/brand/HP.png
Binary file modified dist/brand/HTC.png
Binary file modified dist/brand/HannSpree.png
Binary file modified dist/brand/Hisense.png
Binary file modified dist/brand/Hoozo.png
Binary file modified dist/brand/Huawei.png
Binary file modified dist/brand/IconBIT.png
Binary file modified dist/brand/Ikea.png
Binary file modified dist/brand/Impression.png
Binary file modified dist/brand/Innos.png
Binary file modified dist/brand/JAY-Tech.png
Binary file modified dist/brand/Jolla.png
Binary file modified dist/brand/Just5.png
Binary file modified dist/brand/Kazam.png
Binary file modified dist/brand/Kempler_Strauss.png
Binary file modified dist/brand/Keneksi.png
Binary file modified dist/brand/Kodak.png
Binary file modified dist/brand/Kogan.png
Binary file modified dist/brand/Konrow.png
Binary file modified dist/brand/LAIQ.png
Binary file modified dist/brand/LG.png
Binary file modified dist/brand/LYF.png
Binary file modified dist/brand/Land_Rover.png
Binary file modified dist/brand/Lava.png
Binary file modified dist/brand/Leotec.png
Binary file modified dist/brand/M4tel.png
Binary file modified dist/brand/MTC.png
Binary file modified dist/brand/Maxwest.png
Binary file modified dist/brand/Medion.png
Binary file modified dist/brand/Meizu.png
Binary file modified dist/brand/MicroMax.png
Binary file modified dist/brand/Microsoft.png
Binary file modified dist/brand/Mitsubishi.png
Binary file modified dist/brand/Mobiistar.png
Binary file modified dist/brand/Motorola.png
Binary file modified dist/brand/Movic.png
Binary file modified dist/brand/Myria.png
Binary file modified dist/brand/NGM.png
Binary file modified dist/brand/NOA.png
Binary file modified dist/brand/NUU_Mobile.png
Binary file modified dist/brand/Neffos.png
Binary file modified dist/brand/Nikon.png
Binary file modified dist/brand/Nintendo.png
Binary file modified dist/brand/Noblex.png
Binary file modified dist/brand/Nokia.png
Binary file modified dist/brand/Nvidia.png
Binary file modified dist/brand/O2.png
Binary file modified dist/brand/OPPO.png
Binary file modified dist/brand/O_.png
Binary file modified dist/brand/Obi.png
Binary file modified dist/brand/Odys.png
Binary file modified dist/brand/OnePlus.png
Binary file modified dist/brand/Orange.png
Binary file modified dist/brand/Ordissimo.png
Binary file modified dist/brand/PCD.png
Binary file modified dist/brand/Palm.png
Binary file modified dist/brand/Pantech.png
Binary file modified dist/brand/Philips.png
Binary file modified dist/brand/Plum.png
Binary file modified dist/brand/Polaroid.png
Binary file modified dist/brand/QMobile.png
Binary file modified dist/brand/RIM.png
Binary file modified dist/brand/Rokit.png
Binary file modified dist/brand/Rombica.png
Binary file modified dist/brand/STK.png
Binary file modified dist/brand/Safaricom.png
Binary file modified dist/brand/Samsung.png
Binary file modified dist/brand/Sega.png
Binary file modified dist/brand/Senwa.png
Binary file modified dist/brand/Siemens.png
Binary file modified dist/brand/Smartfren.png
Binary file modified dist/brand/Softbank.png
Binary file modified dist/brand/Sonim.png
Binary file modified dist/brand/Sony.png
Binary file modified dist/brand/Sony_Ericsson.png
Binary file modified dist/brand/Spice.png
Binary file modified dist/brand/T-Mobile.png
Binary file modified dist/brand/TCL.png
Binary file modified dist/brand/TechPad.png
Binary file modified dist/brand/TechniSat.png
Binary file modified dist/brand/Teclast.png
Binary file modified dist/brand/Telefunken.png
Binary file modified dist/brand/Telit.png
Binary file modified dist/brand/Tesla.png
Binary file modified dist/brand/TiPhone.png
Binary file modified dist/brand/Tolino.png
Binary file modified dist/brand/Toshiba.png
Binary file modified dist/brand/TrekStor.png
Binary file modified dist/brand/True.png
Binary file modified dist/brand/Tunisie_Telecom.png
Binary file modified dist/brand/UMIDIGI.png
Binary file modified dist/brand/Uhappy.png
Binary file modified dist/brand/Ulefone.png
Binary file modified dist/brand/Unnecto.png
Binary file modified dist/brand/Unonu.png
Binary file modified dist/brand/Verizon.png
Binary file modified dist/brand/Vernee.png
Binary file modified dist/brand/Vertu.png
Binary file modified dist/brand/Verykool.png
Binary file modified dist/brand/Vestel.png
Binary file modified dist/brand/Vivo.png
Binary file modified dist/brand/Vodafone.png
Binary file modified dist/brand/Vonino.png
Binary file modified dist/brand/Vorago.png
Binary file modified dist/brand/Wiko.png
Binary file modified dist/brand/Wileyfox.png
Binary file modified dist/brand/Wolfgang.png
Binary file modified dist/brand/Xiaomi.png
Binary file modified dist/brand/Yandex.png
Binary file modified dist/brand/ZTE.png
Binary file modified dist/brand/Zen.png
Binary file modified dist/brand/Zync.png
Binary file modified dist/brand/bq.png
Binary file modified dist/brand/iHunt.png
Binary file modified dist/brand/iView.png
Binary file modified dist/browsers/36.png
Binary file modified dist/browsers/3B.png
Binary file modified dist/browsers/A0.png
Binary file modified dist/browsers/AA.png
Binary file modified dist/browsers/AD.png
Binary file modified dist/browsers/AE.png
Binary file modified dist/browsers/AG.png
Binary file modified dist/browsers/AH.png
Binary file modified dist/browsers/AL.png
Binary file modified dist/browsers/AM.png
Binary file modified dist/browsers/AN.png
Binary file modified dist/browsers/AO.png
Binary file modified dist/browsers/AR.png
Binary file modified dist/browsers/AS.png
Binary file modified dist/browsers/AT.png
Binary file modified dist/browsers/AV.png
Binary file modified dist/browsers/AW.png
Binary file modified dist/browsers/AX.png
Binary file modified dist/browsers/BA.png
Binary file modified dist/browsers/BB.png
Binary file modified dist/browsers/BD.png
Binary file modified dist/browsers/BE.png
Binary file modified dist/browsers/BH.png
Binary file modified dist/browsers/BI.png
Binary file modified dist/browsers/BJ.png
Binary file modified dist/browsers/BK.png
Binary file modified dist/browsers/BL.png
Binary file modified dist/browsers/BM.png
Binary file modified dist/browsers/BR.png
Binary file modified dist/browsers/BS.png
Binary file modified dist/browsers/BU.png
Binary file modified dist/browsers/C1.png
Binary file modified dist/browsers/C2.png
Binary file modified dist/browsers/CA.png
Binary file modified dist/browsers/CB.png
Binary file modified dist/browsers/CC.png
Binary file modified dist/browsers/CD.png
Binary file modified dist/browsers/CE.png
Binary file modified dist/browsers/CF.png
Binary file modified dist/browsers/CH.png
Binary file modified dist/browsers/CI.png
Binary file modified dist/browsers/CK.png
Binary file modified dist/browsers/CL.png
Binary file modified dist/browsers/CM.png
Binary file modified dist/browsers/CN.png
Binary file modified dist/browsers/CO.png
Binary file modified dist/browsers/CP.png
Binary file modified dist/browsers/CR.png
Binary file modified dist/browsers/CT.png
Binary file modified dist/browsers/CU.png
Binary file modified dist/browsers/CV.png
Binary file modified dist/browsers/CY.png
Binary file modified dist/browsers/DD.png
Binary file modified dist/browsers/DE.png
Binary file modified dist/browsers/DF.png
Binary file modified dist/browsers/DI.png
Binary file modified dist/browsers/DL.png
Binary file modified dist/browsers/DT.png
Binary file modified dist/browsers/EC.png
Binary file modified dist/browsers/EI.png
Binary file modified dist/browsers/EL.png
Binary file modified dist/browsers/EP.png
Binary file modified dist/browsers/EZ.png
Binary file modified dist/browsers/F1.png
Binary file modified dist/browsers/FA.png
Binary file modified dist/browsers/FB.png
Binary file modified dist/browsers/FD.png
Binary file modified dist/browsers/FE.png
Binary file modified dist/browsers/FF.png
Binary file modified dist/browsers/FK.png
Binary file modified dist/browsers/FL.png
Binary file modified dist/browsers/FM.png
Binary file modified dist/browsers/FN.png
Binary file modified dist/browsers/FR.png
Binary file modified dist/browsers/FU.png
Binary file modified dist/browsers/FY.png
Binary file modified dist/browsers/GB.png
Binary file modified dist/browsers/GE.png
Binary file modified dist/browsers/GP.png
Binary file modified dist/browsers/HC.png
Binary file modified dist/browsers/HH.png
Binary file modified dist/browsers/HJ.png
Binary file modified dist/browsers/HO.png
Binary file modified dist/browsers/HU.png
Binary file modified dist/browsers/I1.png
Binary file modified dist/browsers/I2.png
Binary file modified dist/browsers/I3.png
Binary file modified dist/browsers/I4.png
Binary file modified dist/browsers/IA.png
Binary file modified dist/browsers/IB.png
Binary file modified dist/browsers/IC.png
Binary file modified dist/browsers/ID.png
Binary file modified dist/browsers/IE.png
Binary file modified dist/browsers/IM.png
Binary file modified dist/browsers/IR.png
Binary file modified dist/browsers/IV.png
Binary file modified dist/browsers/IW.png
Binary file modified dist/browsers/JI.png
Binary file modified dist/browsers/JO.png
Binary file modified dist/browsers/JS.png
Binary file modified dist/browsers/KI.png
Binary file modified dist/browsers/KM.png
Binary file modified dist/browsers/KN.png
Binary file modified dist/browsers/KO.png
Binary file modified dist/browsers/KW.png
Binary file modified dist/browsers/KY.png
Binary file modified dist/browsers/KZ.png
Binary file modified dist/browsers/LB.png
Binary file modified dist/browsers/LG.png
Binary file modified dist/browsers/LI.png
Binary file modified dist/browsers/LX.png
Binary file modified dist/browsers/M1.png
Binary file modified dist/browsers/MB.png
Binary file modified dist/browsers/MC.png
Binary file modified dist/browsers/ME.png
Binary file modified dist/browsers/MF.png
Binary file modified dist/browsers/MI.png
Binary file modified dist/browsers/MS.png
Binary file modified dist/browsers/MT.png
Binary file modified dist/browsers/MU.png
Loading

0 comments on commit 1745845

Please sign in to comment.