Skip to content

Commit a80012b

Browse files
authored
[Ubuntu] cache most used GitHub actions
1 parent 32f2e8a commit a80012b

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash -e
2+
################################################################################
3+
## File: action-archive-cache.sh
4+
## Desc: Download latest release from https://github.com/actions/action-verions
5+
## and un-tar to /opt/actionarchivecache
6+
## Maintainer: #actions-runtime and @TingluoHuang
7+
################################################################################
8+
9+
# Source the helpers for use with the script
10+
source $HELPER_SCRIPTS/install.sh
11+
source $HELPER_SCRIPTS/etc-environment.sh
12+
13+
# Prepare directory and env variable for ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE
14+
ACTION_ARCHIVE_CACHE_DIR=/opt/actionarchivecache
15+
mkdir -p $ACTION_ARCHIVE_CACHE_DIR
16+
chmod -R 777 $ACTION_ARCHIVE_CACHE_DIR
17+
echo "Setting up ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE variable to ${ACTION_ARCHIVE_CACHE_DIR}"
18+
addEtcEnvironmentVariable ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE ${ACTION_ARCHIVE_CACHE_DIR}
19+
20+
# Download latest release from github.com/actions/action-versions and untar to /opt/actionarchivecache
21+
downloadUrl=$(get_github_package_download_url "actions/action-versions" "contains(\"action-versions.tar.gz\")")
22+
echo "Downloading action-versions $downloadUrl"
23+
download_with_retries "$downloadUrl" "/tmp" action-versions.tar.gz
24+
tar -xzf /tmp/action-versions.tar.gz -C $ACTION_ARCHIVE_CACHE_DIR
25+
26+
invoke_tests "ActionArchiveCache"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Describe "ActionArchiveCache" {
2+
Context "Action archive cache directory not empty" {
3+
It "/opt/actionarchivecache not empty" {
4+
(Get-ChildItem -Path "/opt/actionarchivecache/*.tar.gz" -Recurse).Count | Should -BeGreaterThan 0
5+
}
6+
}
7+
8+
Context "Action tarball not empty" {
9+
$testCases = Get-ChildItem -Path "/opt/actionarchivecache/*.tar.gz" -Recurse | ForEach-Object { @{ ActionTarball = $_.FullName } }
10+
It "<ActionTarball>" -TestCases $testCases {
11+
param ([string] $ActionTarball)
12+
(Get-Item "$ActionTarball").Length | Should -BeGreaterThan 0
13+
}
14+
}
15+
}

images/linux/ubuntu2004.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
{
197197
"type": "shell",
198198
"scripts": [
199+
"{{template_dir}}/scripts/installers/action-archive-cache.sh",
199200
"{{template_dir}}/scripts/installers/apt-common.sh",
200201
"{{template_dir}}/scripts/installers/azcopy.sh",
201202
"{{template_dir}}/scripts/installers/azure-cli.sh",

images/linux/ubuntu2204.pkr.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ build {
280280
environment_vars = ["HELPER_SCRIPTS=${var.helper_script_folder}", "INSTALLER_SCRIPT_FOLDER=${var.installer_script_folder}", "DEBIAN_FRONTEND=noninteractive"]
281281
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
282282
scripts = [
283+
"${path.root}/scripts/installers/action-archive-cache.sh",
283284
"${path.root}/scripts/installers/apt-common.sh",
284285
"${path.root}/scripts/installers/azcopy.sh",
285286
"${path.root}/scripts/installers/azure-cli.sh",

0 commit comments

Comments
 (0)