-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
77 lines (73 loc) · 2.96 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
name: Setup OpenFOAM
description: Set up a specific version of OpenFOAM
inputs:
openfoam-version:
description: Version of OpenFOAM to set up
cache:
description: Whether to cache the OpenFOAM installation for future runs
default: true
branding:
icon: grid
color: blue
runs:
using: "composite"
steps:
- name: Prepare
id: prep
run: |
if [ $(uname) == "Darwin" ]; then
echo "brew-cask=gerlero/openfoam/openfoam@${{ inputs.openfoam-version }}" >> "$GITHUB_OUTPUT"
echo "openfoam-etc=/Applications/OpenFOAM-v${{ inputs.openfoam-version }}.app/Contents/Resources/etc" >> "$GITHUB_OUTPUT"
elif [ ${{ inputs.openfoam-version }} -lt 1000 ]; then
echo "apt-repository=http://dl.openfoam.org/ubuntu" >> "$GITHUB_OUTPUT"
echo "apt-key=$GITHUB_ACTION_PATH/gpg.key" >> "$GITHUB_OUTPUT"
echo "apt-package=openfoam${{ inputs.openfoam-version }}" >> "$GITHUB_OUTPUT"
echo "openfoam-etc=/opt/openfoam${{ inputs.openfoam-version }}/etc" >> "$GITHUB_OUTPUT"
else
echo "apt-repository=https://dl.openfoam.com/repos/deb" >> "$GITHUB_OUTPUT"
echo "apt-key=$GITHUB_ACTION_PATH/pubkey.gpg" >> "$GITHUB_OUTPUT"
echo "apt-package=openfoam${{ inputs.openfoam-version }}-default" >> "$GITHUB_OUTPUT"
echo "openfoam-etc=/usr/lib/openfoam/openfoam${{ inputs.openfoam-version }}/etc" >> "$GITHUB_OUTPUT"
fi
shell: bash
- name: Add APT repository
if: steps.prep.outputs.apt-repository
uses: gerlero/add-apt-repository@v1
with:
uri: ${{ steps.prep.outputs.apt-repository }}
key: ${{ steps.prep.outputs.apt-key }}
cache: ${{ inputs.cache == 'true' }}
- name: Install OpenFOAM on Linux
if: steps.prep.outputs.apt-package
uses: gerlero/apt-install@v1
with:
packages: ${{ steps.prep.outputs.apt-package }}
install-recommends: false
cache: ${{ inputs.cache == 'true' }}
- name: Install OpenFOAM on macOS
if: steps.prep.outputs.brew-cask
uses: gerlero/brew-install@v1
with:
packages: ${{ steps.prep.outputs.brew-cask }}
type: cask
cache: ${{ inputs.cache == 'true' }}
- name: Activate OpenFOAM for future steps
run: |
old_path="$PATH"
source "${{ steps.prep.outputs.openfoam-etc }}/bashrc" || true
for var in "${!WM_@}"; do
echo "$var=${!var}" >> "$GITHUB_ENV"
done
for var in "${!FOAM_@}"; do
echo "$var=${!var}" >> "$GITHUB_ENV"
done
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> "$GITHUB_ENV"
echo "${PATH/%:$old_path}" >> "$GITHUB_PATH"
shell: bash
- name: Add openfoam command to PATH
if: inputs.openfoam-version >= 1000
run: |
mkdir -p ~/.setup-openfoam/bin
ln -sf $(which openfoam${{ inputs.openfoam-version }}) ~/.setup-openfoam/bin/openfoam
echo ~/.setup-openfoam/bin >> "$GITHUB_PATH"
shell: bash