Skip to content

Commit

Permalink
Split workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
vincerubinetti committed Jun 7, 2024
1 parent 9d96022 commit c68acc0
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 20 deletions.
13 changes: 3 additions & 10 deletions .github/check.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const { readdirSync, readFileSync, existsSync } = require("fs");
const { execSync } = require("child_process");
const { exec } = require("./util");

// strip all metadata to ensure consistency
exec("exiftool -All= -r -overwrite_original ./images");
exec("exiftool -All= -r -overwrite_original ./print");
// install exiftool
exec("sudo apt install exiftool");

checkDimensions("./images", 600, 600);
checkDimensions("./print", 1200, 1200);
Expand Down Expand Up @@ -77,9 +76,3 @@ function checkDimensions(
throw Error(`Colorspace "${colorspace}", expected RGB`);
}
}

function exec(command, print = true) {
const result = execSync(command).toString().trim();
if (print) console.log(result);
return result;
}
8 changes: 8 additions & 0 deletions .github/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { exec } = require("./util");

// install exiftool
exec("sudo apt install exiftool");

// strip all metadata to ensure consistency
exec("exiftool -All= -r -overwrite_original ./images");
exec("exiftool -All= -r -overwrite_original ./print");
7 changes: 7 additions & 0 deletions .github/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { execSync } = require("child_process");

export function exec(command, print = true) {
const result = execSync(command).toString().trim();
if (print) console.log(result);
return result;
}
15 changes: 5 additions & 10 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Check and clean files
name: Check files

on: pull_request
on:
pull_request:
branches:
- main

jobs:
check:
Expand All @@ -11,13 +14,5 @@ jobs:
with:
ref: ${{ github.head_ref }}

- name: Install exiftool
run: sudo apt install exiftool

- name: Run script
run: node ./.github/check.js

- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update files"
21 changes: 21 additions & 0 deletions .github/workflows/clean.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Clean files

on:
push:
branches:
- main

jobs:
clean:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run script
run: node ./.github/clean.js

- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Clean files"

0 comments on commit c68acc0

Please sign in to comment.