Skip to content

Commit

Permalink
Improve caching on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
gerlero committed Aug 27, 2024
2 parents dc04d90 + 2caaddb commit af479ae
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ runs:
id: prep
run: |
if [ $(uname) == "Darwin" ]; then
brew tap gerlero/openfoam
echo "openfoam-app-version=$(brew info gerlero/openfoam/openfoam | head -n 1 | awk '{print $3}')" >> "$GITHUB_OUTPUT"
echo "openfoam-etc=/Applications/OpenFOAM-v${{ inputs.openfoam-version }}.app/Contents/Resources/etc" >> "$GITHUB_OUTPUT"
elif [ ${{ inputs.openfoam-version }} -lt 1000 ]; then
which wget && which add-apt-repository || echo "apt-packages-pre=wget software-properties-common" >> $GITHUB_OUTPUT
echo "apt-packages=openfoam${{ inputs.openfoam-version }}" >> $GITHUB_OUTPUT
echo "openfoam-etc=/opt/openfoam${{ inputs.openfoam-version }}/etc" >> "$GITHUB_OUTPUT"
else
which curl || echo "apt-packages-pre=curl ca-certificates" >> $GITHUB_OUTPUT
which wget || echo "apt-packages-pre=wget gnupg" >> $GITHUB_OUTPUT
echo "apt-packages=openfoam${{ inputs.openfoam-version }}-default" >> $GITHUB_OUTPUT
echo "openfoam-etc=/usr/lib/openfoam/openfoam${{ inputs.openfoam-version }}/etc" >> "$GITHUB_OUTPUT"
fi
Expand All @@ -32,7 +34,6 @@ runs:
uses: gerlero/apt-install@v1
with:
packages: ${{ steps.prep.outputs.apt-packages-pre }}
install-recommends: false
cache: ${{ inputs.cache && inputs.cache != 'false' }}
- name: Add OpenFOAM APT repository (openfoam.org)
if: steps.prep.outputs.apt-packages && inputs.openfoam-version < 1000
Expand All @@ -45,7 +46,7 @@ runs:
fi
}
sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key > /etc/apt/trusted.gpg.d/openfoam.asc"
sudo wget -O /etc/apt/trusted.gpg.d/openfoam.asc https://dl.openfoam.org/gpg.key
sudo add-apt-repository http://dl.openfoam.org/ubuntu
shell: bash
- name: Add OpenFOAM APT repository (openfoam.com)
Expand All @@ -59,7 +60,7 @@ runs:
fi
}
curl -s https://dl.openfoam.com/add-debian-repo.sh | sudo bash
wget -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash
shell: bash
- name: Install OpenFOAM on Linux
if: steps.prep.outputs.apt-packages
Expand All @@ -69,22 +70,24 @@ runs:
install-recommends: false
update: ${{ inputs.openfoam-version < 1000 }}
cache: ${{ inputs.cache && inputs.cache != 'false' }}
- name: Get OS version
if: runner.os == 'macOS' && inputs.cache && inputs.cache != 'false'
id: os-version
uses: sersoft-gmbh/os-version-action@v3
- name: Cache OpenFOAM on macOS
- name: Restore OpenFOAM on macOS from cache
if: runner.os == 'macOS' && inputs.cache && inputs.cache != 'false'
id: cache-macos
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
key: setup-openfoam-${{ inputs.openfoam-version }}-${{ runner.os }}-${{ steps.os-version.outputs.version }}-${{ runner.arch }}
path: /Applications/OpenFOAM-v${{ inputs.openfoam-version }}.app
key: setup-openfoam-${{ runner.os }}-${{ runner.arch }}-${{ inputs.openfoam-version }}-${{ steps.prep.outputs.openfoam-app-version }}
- name: Install OpenFOAM on macOS
if: runner.os == 'macOS' && steps.cache-macos.outputs.cache-hit != 'true'
run: |
brew install --no-quarantine gerlero/openfoam/openfoam@${{ inputs.openfoam-version }}
shell: bash
- name: Save OpenFOAM on macOS to cache
if: runner.os == 'macOS' && inputs.cache && inputs.cache != 'false' && steps.cache-macos.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: /Applications/OpenFOAM-v${{ inputs.openfoam-version }}.app
key: ${{ steps.cache-macos.outputs.cache-primary-key }}
- name: Activate OpenFOAM for future steps
run: |
OLD_PATH="$PATH"
Expand Down

0 comments on commit af479ae

Please sign in to comment.