-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
102 lines (84 loc) · 3.03 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Setup cabal-cache for S3
description: Setup cabal-cache to store Haskell packages cache on S3
inputs:
awsKey:
description: 'AWS Access Key ID'
required: true
awsSecretKey:
description: 'AWS Secret Key'
required: true
awsRegion:
description: 'AWS Region'
required: true
archiveUri:
description: 'Archive URI in form of "s3://bucket/path"'
required: true
cabalStorePath:
description: 'Path to local cabal store'
required: true
threadsNum:
description: 'Number of threads concurrently uploading to S3'
required: false
default: "4"
branding:
icon: archive
color: green
runs:
using: "composite"
steps:
- name: Downloading cabal-cache
shell: bash
env:
CI_TEMP: ${{runner.temp}}
run: |
export CI_TEMP="$(echo "/$CI_TEMP" | sed 's/\\/\//g' | sed 's/://')"
export LOCAL_BIN="$HOME/.local/bin"
mkdir -p "$LOCAL_BIN"
if [[ ! ":$PATH:" == *":$HOME/.cabal/bin:"* ]]; then
export PATH="$LOCAL_BIN:$PATH"
echo "PATH=$LOCAL_BIN:$PATH" >> $GITHUB_ENV
fi
if ! command -v cabal-cache &> /dev/null; then
case "${{runner.os}}" in
Linux) CI_OS=linux ;;
Windows) CI_OS=nt ;;
macOS) CI_OS=osx ;;
*) echo "Unsupported OS: ${{ runner.os }}"; exit 1;;
esac
echo "Downloading from https://dl.haskellworks.io/binaries/cabal-cache/cabal-cache_x86_64_${CI_OS}.tar.gz"
curl -L "https://dl.haskellworks.io/binaries/cabal-cache/cabal-cache_x86_64_${CI_OS}.tar.gz" \
-o "$CI_TEMP/cabal-cache.tar.gz"
tar zxvf "$CI_TEMP/cabal-cache.tar.gz" -C "$LOCAL_BIN"
fi
- name: Configure environment
shell: bash
run: |
echo '_CABAL_CACHE_AWS_ACCESS_KEY_ID__="${{ inputs.awsKey }}"' >> $GITHUB_ENV
echo '_CABAL_CACHE_AWS_SECRET_ACCESS_KEY__="${{ inputs.awsSecretKey }}"' >> $GITHUB_ENV
echo '_CABAL_CACHE_ARCHIVE_URI__="${{ inputs.archiveUri }}"' >> $GITHUB_ENV
cat $GITHUB_ENV
- name: Configure scripts
shell: bash
run: |
cat <<EOF > $HOME/.local/bin/cabal-cache-op
#!/usr/bin/env bash
CMD=\$1
export AWS_ACCESS_KEY_ID="\$_CABAL_CACHE_AWS_ACCESS_KEY_ID__"
export AWS_SECRET_ACCESS_KEY="\$_CABAL_CACHE_AWS_SECRET_ACCESS_KEY__"
cabal-cache \$CMD \
--threads ${{ inputs.threadsNum }} \
--archive-uri \$_CABAL_CACHE_ARCHIVE_URI__ \
--region ${{ inputs.awsRegion }} \
--store-path "${{ inputs.cabalStorePath }}"
EOF
cat <<EOF >> $HOME/.local/bin/cabal-cache-store
#!/usr/bin/env bash
cabal-cache-op sync-to-archive
EOF
cat <<EOF >> $HOME/.local/bin/cabal-cache-restore
#!/usr/bin/env bash
cabal-cache-op sync-from-archive
EOF
chmod +x $HOME/.local/bin/cabal-cache-op
chmod +x $HOME/.local/bin/cabal-cache-store
chmod +x $HOME/.local/bin/cabal-cache-restore