Skip to content

Commit 0a0bd15

Browse files
committed
feat: specific ruby version support (#53)
1 parent b4edbc7 commit 0a0bd15

File tree

4 files changed

+48
-5
lines changed

4 files changed

+48
-5
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ inputs:
2323
cname:
2424
description: 'The cname to use for the site'
2525
required: false
26+
ruby_ver:
27+
description: 'The Ruby version'
28+
required: false
2629
bundler_ver:
2730
description: 'The Bundler version'
2831
required: false

entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ SSH_PRIVATE_KEY=${INPUT_SSH_PRIVATE_KEY:=}
1212
ACTOR=${INPUT_ACTOR}
1313
REPOSITORY=${INPUT_REPOSITORY}
1414
BRANCH=${INPUT_BRANCH}
15-
BUNDLER_VER=${INPUT_BUNDLER_VER:=~>2.4.0}
15+
RUBY_VER=${INPUT_RUBY_VER:=3.2.0}
16+
BUNDLER_VER=${INPUT_BUNDLER_VER:=~>2.5.0}
1617
JEKYLL_SRC=${INPUT_JEKYLL_SRC:=./}
1718
JEKYLL_CFG=${INPUT_JEKYLL_CFG:=./_config.yml}
1819
JEKYLL_BASEURL=${INPUT_JEKYLL_BASEURL:=}
@@ -149,4 +150,8 @@ if [[ -n "${SSH_PRIVATE_KEY}" ]]; then
149150
rm -f ${SSH_PRIVATE_KEY_PATH}
150151
fi
151152

153+
# Update cache key
154+
echo "Update cache key..."
155+
source ${SCRIPT_DIR}/script/update_cache_key.sh
156+
152157
exit ${PROVIDER_EXIT_CODE}

script/init_environment.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
# Generate a default secret key
4+
# To prevent archlinux-keyring from no secret key available to sign with
5+
pacman-key --init
6+
37
# Update packages database
48
pacman -Syu --noconfirm
59

@@ -11,11 +15,30 @@ if [[ -n "${SSH_PRIVATE_KEY}" ]]; then
1115
pacman -S --noconfirm openssh
1216
fi
1317

14-
# Installing ruby libraries
15-
pacman -S --noconfirm ruby2.7 ruby-bundler
18+
# Install asdf-vm for tools' version management
19+
ASDF_HOME=${WORKING_DIR}/.asdf
20+
21+
if [[ ! -f "${ASDF_HOME}/asdf.sh" ]]; then
22+
git clone https://github.com/asdf-vm/asdf.git \
23+
${ASDF_HOME} --branch v0.14.0
24+
fi
25+
26+
source ${ASDF_HOME}/asdf.sh
27+
28+
# Fix invalid cache to asdf tools' installation
29+
ln -s ${ASDF_HOME} ${HOME}/.asdf
30+
31+
# Install ruby environment
32+
pacman -S --noconfirm libyaml
33+
34+
if ! asdf list ruby ${RUBY_VER} &>/dev/null; then
35+
# Clean up ruby environments avoiding unnecessary cache
36+
rm -rf ${ASDF_HOME}/installs/ruby
37+
asdf plugin add ruby
38+
asdf install ruby ${RUBY_VER}
39+
fi
1640

17-
# Setting default ruby version
18-
cp /usr/bin/ruby-2.7 /usr/bin/ruby
41+
asdf global ruby ${RUBY_VER}
1942

2043
# debug
2144
ruby -v && bundle version

script/update_cache_key.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
CACHE_KEY_PATH=$HOME/cache.key
4+
5+
function sha1sumx() {
6+
if [[ -f "$1" ]]; then
7+
echo $(sha1sum "$1")>> $CACHE_KEY_PATH
8+
fi
9+
}
10+
11+
sha1sumx $(find "${WORKING_DIR}" -not -path "**/.asdf/**" -iname '**Gemfile.lock')
12+
sha1sumx ${HOME}/.tool-versions

0 commit comments

Comments
 (0)