|
| 1 | +# Image Actions will run in the following scenarios: |
| 2 | +# - on Pull Requests containing images (not including forks) |
| 3 | +# - on pushing of images to `main` (for forks) |
| 4 | +# - on demand (https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/) |
| 5 | +# - at 11 PM every Sunday in anything gets missed with any of the above scenarios |
| 6 | +# For Pull Requests, the images are added to the PR. |
| 7 | +# For other scenarios, a new PR will be opened if any images are compressed. |
| 8 | +name: Compress images |
| 9 | +on: |
| 10 | + pull_request: |
| 11 | + paths: |
| 12 | + - '**.jpg' |
| 13 | + - '**.jpeg' |
| 14 | + - '**.png' |
| 15 | + - '**.webp' |
| 16 | + push: |
| 17 | + branches: |
| 18 | + - main |
| 19 | + paths: |
| 20 | + - '**.jpg' |
| 21 | + - '**.jpeg' |
| 22 | + - '**.png' |
| 23 | + - '**.webp' |
| 24 | + workflow_dispatch: |
| 25 | + schedule: |
| 26 | + - cron: '00 23 * * 0' |
| 27 | +jobs: |
| 28 | + build: |
| 29 | + name: calibreapp/image-actions |
| 30 | + runs-on: ubuntu-latest |
| 31 | + # Only run on main repo on and PRs that match the main repo. |
| 32 | + if: | |
| 33 | + github.repository == 'GDevelopApp/GDevelop-documentation' && |
| 34 | + (github.event_name != 'pull_request' || |
| 35 | + github.event.pull_request.head.repo.full_name == github.repository) |
| 36 | + steps: |
| 37 | + - name: Checkout Branch |
| 38 | + uses: actions/checkout@v2 |
| 39 | + - name: Compress Images |
| 40 | + id: calibre |
| 41 | + uses: calibreapp/image-actions@main |
| 42 | + with: |
| 43 | + githubToken: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + # For non-Pull Requests, run in compressOnly mode and we'll PR after. |
| 45 | + compressOnly: ${{ github.event_name != 'pull_request' }} |
| 46 | + - name: Create Pull Request |
| 47 | + # If it's not a Pull Request then commit any changes as a new PR. |
| 48 | + if: | |
| 49 | + github.event_name != 'pull_request' && |
| 50 | + steps.calibre.outputs.markdown != '' |
| 51 | + uses: peter-evans/create-pull-request@v3 |
| 52 | + with: |
| 53 | + title: Auto Compress Images |
| 54 | + branch-suffix: timestamp |
| 55 | + commit-message: Compress Images |
| 56 | + body: ${{ steps.calibre.outputs.markdown }} |
0 commit comments