Skip to content

Commit

Permalink
Allow to add additional apk keys
Browse files Browse the repository at this point in the history
Resolves #1
  • Loading branch information
jirutka committed Jun 18, 2022
1 parent f235581 commit 5ade4b0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ Alpine branch (aka release) to install: `vMAJOR.MINOR`, `latest-stable`, or `edg
Example: `{alpine-latest}` +
Default: `latest-stable`

extra-keys::
A list of paths of additional trusted keys (for installing packages from the _extra-repositories_) to copy into _/etc/apk/keys/_.
The paths should be relative to the workspace directory (the default location of your repository when using the checkout action).
+
Example: `.keys/pkgs@example.org-56d0d9fd.rsa.pub`

extra-repositories::
A list of additional Alpine repositories to add into _/etc/apk/repositories_ (Alpine’s official _main_ and _community_ repositories are always added).
+
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ inputs:
description: Alpine branch (aka release) to install (e.g. `v3.15`, `latest-stable`, `edge`).
required: false
default: latest-stable
extra-keys:
description: >
A list of paths of additional trusted keys (for installing packages from the
extra-repositories) to copy into /etc/apk/keys/. The paths should be relative to the
workspace directory (the default location of your repository when using the checkout action).
required: false
default: ''
extra-repositories:
description: >
A list of additional Alpine repositories to add into /etc/apk/repositories (Alpine's official
Expand Down Expand Up @@ -71,6 +78,7 @@ runs:
INPUT_APK_TOOLS_URL: ${{ inputs.apk-tools-url }}
INPUT_ARCH: ${{ inputs.arch }}
INPUT_BRANCH: ${{ inputs.branch }}
INPUT_EXTRA_KEYS: ${{ inputs.extra-keys }}
INPUT_EXTRA_REPOSITORIES: ${{ inputs.extra-repositories }}
INPUT_MIRROR_URL: ${{ inputs.mirror-url }}
INPUT_PACKAGES: ${{ inputs.packages }}
Expand Down
13 changes: 13 additions & 0 deletions setup-alpine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# - INPUT_APK_TOOLS_URL
# - INPUT_ARCH
# - INPUT_BRANCH
# - INPUT_EXTRA_KEYS
# - INPUT_EXTRA_REPOSITORIES
# - INPUT_MIRROR_URL
# - INPUT_PACKAGES
Expand Down Expand Up @@ -137,6 +138,13 @@ case "$INPUT_BRANCH" in
"Expected 'v[0-9].[0-9]+' (e.g. v3.15), edge, or latest-stable, but got: $INPUT_BRANCH."
esac

for path in $INPUT_EXTRA_KEYS; do
if ! [ -r "$GITHUB_WORKSPACE/$path" ]; then
die 'Invalid input parameter: extra-keys' \
"File does not exist in workspace or is not readable: $path."
fi
done

if ! expr "$INPUT_SHELL_NAME" : [a-zA-Z][a-zA-Z0-9_.~+@%-]*$ >/dev/null; then
die 'Invalid input parameter: shell-name' \
"Expected value matching regex ^[a-zA-Z][a-zA-Z0-9_.~+@%-]*$, but got: $INPUT_SHELL_NAME."
Expand Down Expand Up @@ -216,6 +224,11 @@ printf '%s\n' \
| tee etc/apk/repositories

cp -r "$SCRIPT_DIR"/keys etc/apk/

for path in $INPUT_EXTRA_KEYS; do
cp "$GITHUB_WORKSPACE/$path" etc/apk/keys/
done

cat /etc/resolv.conf > etc/resolv.conf

info "Installing base packages into $(pwd)"
Expand Down

0 comments on commit 5ade4b0

Please sign in to comment.