-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
97 lines (90 loc) · 3.01 KB
/
action.yml
File metadata and controls
97 lines (90 loc) · 3.01 KB
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
name: "OpenAF's setup action"
description: "Setups OpenAF to use it on a GitHub action"
branding:
icon : 'command'
color: 'black'
inputs:
dist:
description: 'The OpenAF distribution to use'
required: false
version:
description: 'A specific OpenAF version to use'
required: false
opacks:
description: 'A comma separated list of OpenAF public oPacks to pre-install'
required: false
runs:
using: "composite"
steps:
# -------------------
- name: Setup Java 25
uses: actions/setup-java@v5
with:
java-version: 25
distribution: 'temurin'
# -------------------------------
- name : Check for OpenAF runtime
shell: bash
run : | #js
if [ ! -f /tmp/oaf/oaf ]; then
CDIR=`pwd`
mkdir /tmp/oaf
cd /tmp/oaf
DIST=${{ inputs.dist }}
DIST=$(echo "$DIST" | xargs)
if [ "$DIST" = "stable" ]; then
DIST=""
fi
VERSION=${{ inputs.version }}
VERSION=$(echo "$VERSION" | xargs)
if [ -n "$VERSION" ]; then
VERSION="-$VERSION"
else
VERSION=""
fi
# Build download URL without producing a double slash when DIST is empty
if [ -n "$DIST" ]; then
URL="https://openaf.io/$DIST/openaf$VERSION.jar.repacked"
else
URL="https://openaf.io/openaf$VERSION.jar.repacked"
fi
curl "$URL" -o openaf.jar
java -jar openaf.jar --install
OPACKS=${{ inputs.opacks }}
OPACKS=$(echo "$OPACKS" | xargs)
if [ -n "$OPACKS" ]; then
IFS=',' read -ra PACKAGES <<< "$OPACKS"
for package in "${PACKAGES[@]}"; do
echo "Installing $package..."
/tmp/oaf/opack install "$package"
done
fi
cd $CDIR
fi
# Check if sudo is available
if command -v sudo >/dev/null 2>&1 && sudo -n true 2>/dev/null; then
BIN_DIR="/usr/bin"
for script in oaf oaf-sb oafp oafp-sb ojob ojob-sb opack openaf openaf-sb pyoaf; do
if [ ! -f $BIN_DIR/$script ] && [ -f /tmp/oaf/$script ]; then
echo "Creating $BIN_DIR/$script..."
echo -e "#!/bin/sh\n/tmp/oaf/$script \"\$@\"" | sudo tee $BIN_DIR/$script > /dev/null
sudo chmod +x $BIN_DIR/$script
fi
done
else
# Use user's bin directory if sudo is not available
BIN_DIR="$HOME/.local/bin"
mkdir -p "$BIN_DIR"
for script in oaf oaf-sb oafp oafp-sb ojob ojob-sb opack openaf openaf-sb pyoaf; do
if [ ! -f $BIN_DIR/$script ] && [ -f /tmp/oaf/$script ]; then
echo "Creating $BIN_DIR/$script..."
echo -e "#!/bin/sh\n/tmp/oaf/$script \"\$@\"" > $BIN_DIR/$script
chmod +x $BIN_DIR/$script
fi
done
# Add bin dir to PATH via GITHUB_PATH if in GitHub Actions
if [ -n "$GITHUB_PATH" ]; then
echo "$BIN_DIR" >> $GITHUB_PATH
echo "Added $BIN_DIR to PATH"
fi
fi