Skip to content

Commit

Permalink
Workflow dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Nov 6, 2024
1 parent a7860d1 commit ad0d7d5
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 19 deletions.
27 changes: 8 additions & 19 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,29 +104,18 @@ jobs:

oxipng:
runs-on: ubuntu-latest
permissions:
contents: write # git push
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
#token: ${{ secrets.PR_PUSH_TOKEN }}

- 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
# Dispatch workflow
- uses: benc-uk/workflow-dispatch@v1
with:
author_name: 'Godot-Rust Automation'
author_email: '[email protected]'
message: 'Auto-reduce PNG sizes'
add: 'src/**/*.png'
#token: ${{ secrets.GITHUB_TOKEN }}
workflow: 'push-oxipng-image.yml'
inputs: '{ "repository": "${{ github.event.pull_request.head.repo.full_name }}", "branch": "${{ github.event.pull_request.head.ref }}" }'
59 changes: 59 additions & 0 deletions .github/workflows/push-oxipng-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright (c) godot-rust; Bromeon and contributors.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

name: "Push oxipng image"

on:
workflow_dispatch:
inputs:
repository:
description: "owner/repo"
required: true
branch:
description: "branch used for PR"
required: true

env:
OXIPNG_VERSION: "9.1.1"

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

jobs:
oxipng-write:
runs-on: ubuntu-latest
permissions:
contents: write # git push
steps:

- uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.repository }}
ref: ${{ github.event.inputs.branch }}
token: ${{ secrets.PR_PUSH_TOKEN }}

- 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: '[email protected]'
message: 'Auto-reduce PNG sizes'
add: 'src/**/*.png'

0 comments on commit ad0d7d5

Please sign in to comment.