mirror of
https://codeberg.org/icewind/attic-action.git
synced 2026-06-03 09:34:11 +02:00
Add pushFilter to allow filtering cache derivations
This allows filtering derivations to be pushed via an optional `pushFilter` variable. The use case behind it is to not push the actually built derivation, but only runtime and build dependencies. Signed-off-by: Sascha Grunert <mail@saschagrunert.de>
This commit is contained in:
parent
26cfe1ed98
commit
f1560b98ab
4 changed files with 13 additions and 3 deletions
|
|
@ -13,6 +13,8 @@ inputs:
|
||||||
description: 'Signing key secret retrieved after creating binary cache on https://cachix.org'
|
description: 'Signing key secret retrieved after creating binary cache on https://cachix.org'
|
||||||
skipPush:
|
skipPush:
|
||||||
description: 'Set to true to disable pushing build results to the cache'
|
description: 'Set to true to disable pushing build results to the cache'
|
||||||
|
pushFilter:
|
||||||
|
description: 'Regular expression to exclude derivations for the cache push, for example "(-source$|nixpkgs\.tar\.gz$)". Warning: this filter doet not guarantee it will not get pushed in case the path is part of the closure of something that will get pushed.'
|
||||||
installCommand:
|
installCommand:
|
||||||
description: 'Override the default cachix installation method'
|
description: 'Override the default cachix installation method'
|
||||||
branding:
|
branding:
|
||||||
|
|
|
||||||
3
dist/main/index.js
vendored
3
dist/main/index.js
vendored
|
|
@ -1042,6 +1042,7 @@ const extraPullNames = core.getInput('extraPullNames');
|
||||||
const signingKey = core.getInput('signingKey');
|
const signingKey = core.getInput('signingKey');
|
||||||
const authToken = core.getInput('authToken');
|
const authToken = core.getInput('authToken');
|
||||||
const skipPush = core.getInput('skipPush');
|
const skipPush = core.getInput('skipPush');
|
||||||
|
const pushFilter = core.getInput('pushFilter');
|
||||||
const cachixExecutable = process.env.HOME + '/.nix-profile/bin/cachix';
|
const cachixExecutable = process.env.HOME + '/.nix-profile/bin/cachix';
|
||||||
const installCommand = core.getInput('installCommand') ||
|
const installCommand = core.getInput('installCommand') ||
|
||||||
"nix-env --quiet -j8 -iA cachix -f https://cachix.org/api/v1/install";
|
"nix-env --quiet -j8 -iA cachix -f https://cachix.org/api/v1/install";
|
||||||
|
|
@ -1086,7 +1087,7 @@ function upload() {
|
||||||
core.info('Pushing is disabled as skipPush is set to true');
|
core.info('Pushing is disabled as skipPush is set to true');
|
||||||
}
|
}
|
||||||
else if (signingKey !== "" || authToken !== "") {
|
else if (signingKey !== "" || authToken !== "") {
|
||||||
yield exec.exec(`${__dirname}/push-paths.sh`, [cachixExecutable, name]);
|
yield exec.exec(`${__dirname}/push-paths.sh`, [cachixExecutable, name, pushFilter]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info('Pushing is disabled as signing key nor auth token are set.');
|
core.info('Pushing is disabled as signing key nor auth token are set.');
|
||||||
|
|
|
||||||
8
dist/main/push-paths.sh
vendored
8
dist/main/push-paths.sh
vendored
|
|
@ -1,4 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
comm -13 <(sort /tmp/store-path-pre-build) <("$(dirname "$0")"/list-nix-store.sh) | "$1" push -j8 "$2"
|
PATHS=$(comm -13 <(sort /tmp/store-path-pre-build) <("$(dirname "$0")"/list-nix-store.sh))
|
||||||
|
|
||||||
|
if [[ $3 != "" ]]; then
|
||||||
|
PATHS=$(echo "$PATHS" | grep -vE "$3")
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$PATHS" | "$1" push -j8 "$2"
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ const extraPullNames = core.getInput('extraPullNames');
|
||||||
const signingKey = core.getInput('signingKey');
|
const signingKey = core.getInput('signingKey');
|
||||||
const authToken = core.getInput('authToken')
|
const authToken = core.getInput('authToken')
|
||||||
const skipPush = core.getInput('skipPush');
|
const skipPush = core.getInput('skipPush');
|
||||||
|
const pushFilter = core.getInput('pushFilter');
|
||||||
const cachixExecutable = process.env.HOME + '/.nix-profile/bin/cachix';
|
const cachixExecutable = process.env.HOME + '/.nix-profile/bin/cachix';
|
||||||
const installCommand =
|
const installCommand =
|
||||||
core.getInput('installCommand') ||
|
core.getInput('installCommand') ||
|
||||||
|
|
@ -56,7 +57,7 @@ async function upload() {
|
||||||
if (skipPush === 'true') {
|
if (skipPush === 'true') {
|
||||||
core.info('Pushing is disabled as skipPush is set to true');
|
core.info('Pushing is disabled as skipPush is set to true');
|
||||||
} else if (signingKey !== "" || authToken !== "") {
|
} else if (signingKey !== "" || authToken !== "") {
|
||||||
await exec.exec(`${__dirname}/push-paths.sh`, [cachixExecutable, name]);
|
await exec.exec(`${__dirname}/push-paths.sh`, [cachixExecutable, name, pushFilter]);
|
||||||
} else {
|
} else {
|
||||||
core.info('Pushing is disabled as signing key nor auth token are set.');
|
core.info('Pushing is disabled as signing key nor auth token are set.');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue