Create Deployment Spack #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Deployment Spack | |
on: | |
workflow_dispatch: | |
inputs: | |
spack-git-url: | |
type: string | |
required: true | |
default: 'https://github.com/access-nri/spack.git' | |
description: Git URL for the spack repository | |
spack-version: | |
type: string | |
required: true | |
description: A version of spack | |
spack-packages-version: | |
type: string | |
required: true | |
default: main | |
description: A version of ACCESS-NRI/spack-packages | |
spack-config-version: | |
type: string | |
required: true | |
default: main | |
description: A version of ACCESS-NRI/spack-config | |
deployment-location: | |
type: string | |
required: true | |
description: | | |
A path in the deployment environment where Spack should be created. | |
For example, if it is `opt/spack`, spack will be installed under `opt/spack/<spack-version>/` | |
jobs: | |
log-inputs: | |
name: Log Inputs | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
echo '::notice::url = `${{ inputs.spack-git-url }}`, spack version = `${{ inputs.spack-version }}`, spack-packages version = `${{ inputs.spack-packages-version }}`, spack-config version = `${{ inputs.spack-config-version }}`, deployment location = `${{ inputs.deployment-location }}`' | |
create-spack: | |
name: Spack | |
runs-on: ubuntu-latest | |
# all `secrets` and `vars` inherit from the 'Gadi Spack' GitHub Environment, | |
# which can be found in the Settings of the repository. | |
environment: "Gadi Spack" | |
steps: | |
- name: Setup SSH | |
id: ssh | |
uses: access-nri/actions/.github/actions/setup-ssh@main | |
with: | |
hosts: ${{ secrets.SSH_HOST }} | |
private-key: ${{ secrets.SSH_KEY }} | |
- name: Strip Spack Version | |
id: strip | |
# this step removes the 'release/' part from some spack tags, so our | |
# directory structure doesn't contain a 'releases' subdirectory | |
run: echo "version-dir=$(echo '${{ inputs.spack-version }}' | cut --delimiter 'v' --fields 2)" >> $GITHUB_OUTPUT | |
- name: Install | |
env: | |
ROOT_VERSION_LOCATION: ${{ inputs.deployment-location }}/${{ steps.strip.outputs.version-dir }} | |
# This step will fail if `mkdir` fails to create a version directory (e.g. `0.20` is already deployed and exists) | |
run: | | |
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT' | |
mkdir ${{ env.ROOT_VERSION_LOCATION }} || exit $? | |
git -C ${{ env.ROOT_VERSION_LOCATION }} clone -c feature.manyFiles=true ${{ inputs.spack-git-url }} --branch ${{ inputs.spack-version }} --single-branch --depth=1 | |
git -C ${{ env.ROOT_VERSION_LOCATION }} clone https://github.com/ACCESS-NRI/spack-packages.git --branch ${{ inputs.spack-packages-version }} | |
git -C ${{ env.ROOT_VERSION_LOCATION }} clone https://github.com/ACCESS-NRI/spack-config.git --branch ${{ inputs.spack-config-version }} | |
ln -s -r -v ${{ env.ROOT_VERSION_LOCATION }}/spack-config/v${{ steps.strip.outputs.version-dir }}/${{ vars.DEPLOYMENT_TARGET }}/* ${{ env.ROOT_VERSION_LOCATION }}/spack/etc/spack/ | |
mkdir ${{ env.ROOT_VERSION_LOCATION }}/release | |
# Create restricted folders | |
mkdir -p ${{ env.ROOT_VERSION_LOCATION }}/restricted/ukmo/release | |
mkdir -p ${{ env.ROOT_VERSION_LOCATION }}/restricted/ukmo/source_cache | |
mkdir -p $TMPDIR/restricted/spack-stage | |
setfacl --recursive -m \ | |
"g:vk83_w:r-X,g:ki32_mosrs:r-X,g::---,other::---,d:g:vk83_w:r-X,d:g:ki32_mosrs:r-X,d:g::---,d:other::---" \ | |
${{ env.ROOT_VERSION_LOCATION }}/restricted $TMPDIR/restricted | |
EOT |