Update optimize-docs-images.yml #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Optimize Docs Images | |
on: | |
pull_request: | |
branches: ["main","devel"] | |
types: [closed] | |
jobs: | |
optimize-images: | |
if: ${{github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true}} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libmagick++-dev | |
- name: Install R packages and run script | |
run: | | |
R -e 'install.packages(c("magick", "tools"), repos = "https://cloud.r-project.org/")' | |
Rscript ./scripts/optimize.R | |
- name: Commit and push optimized images | |
if: github.ref == 'refs/heads/devel' && github.event_name == 'push' | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add docs/assets | |
git commit -m 'Optimize docs images' | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |