Skip to content

Commit

Permalink
Include oxipng in CI (#19)
Browse files Browse the repository at this point in the history
Automatically shrinks submitted PNGs in pull requests.

Update actions/checkout@v3 -> v4.
  • Loading branch information
Bromeon authored Dec 12, 2023
1 parent a6c1d64 commit 2ee53e7
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ env:
MDBOOK_TOC_VERSION: "0.13.0"
MDBOOK_ADMONISH_VERSION: "1.10.1"
MDBOOK_BIN: "/tmp/mdbook-bin"
OXIPNG_VERSION: "9.0.0"

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
contents: write # git push for oxipng
pages: write
id-token: write

Expand All @@ -30,7 +31,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4

# Note: actions-rs/install@v0.1 was considered, but a full 'cargo install' is unnecessarily slow and the cache mechanism is not reliable
# (error "Unable to download mdbook == 0.4.14 from the tool cache: Error: Unexpected HTTP response: 403")
Expand Down Expand Up @@ -67,7 +68,7 @@ jobs:
markdown-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: "Install markdownlint-cli2"
run: npm install -g markdownlint-cli2
Expand All @@ -86,7 +87,7 @@ jobs:
license-guard:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: "Check license headers"
uses: apache/skywalking-eyes/header@v0.5.0
Expand All @@ -99,11 +100,32 @@ jobs:
mode: check
# mode: fix

# - name: "Commit changes"
# uses: EndBug/add-and-commit@v9
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# author_name: 'Godot-Rust Automation'
# author_email: 'actions@github.com'
# message: 'Auto-apply license headers'

oxipng:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: "Run oxipng to reduce PNG sizes"
run: |
wget https://github.com/shssoichiro/oxipng/releases/download/v${OXIPNG_VERSION}/oxipng-${OXIPNG_VERSION}-x86_64-unknown-linux-musl.tar.gz \
-O /tmp/oxipng.tar.gz
tar -xvzf /tmp/oxipng.tar.gz -C /tmp
mv /tmp/oxipng-${OXIPNG_VERSION}-x86_64-unknown-linux-musl/oxipng ./oxipng
chmod +x ./oxipng
./oxipng --version
./oxipng --strip safe --alpha -r src
# See https://github.com/EndBug/add-and-commit#add--commit.
- name: "Commit changes"
uses: EndBug/add-and-commit@v9
with:
author_name: 'Godot-Rust Automation'
author_email: '115185599+GodotRust@users.noreply.github.com'
message: 'Auto-reduce PNG sizes'
add: 'src/**/*.png'

0 comments on commit 2ee53e7

Please sign in to comment.