Skip to content

Commit

Permalink
Update update-module.yml: Generate different modulefiles for release/…
Browse files Browse the repository at this point in the history
…pre-release modules
  • Loading branch information
jo-basevi committed Jun 14, 2024
1 parent d5b30d2 commit 2d5f229
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ jobs:
echo "New payu/dev environment unpacked to ${{ env.PAYU_ENVIRONMENT_LOCATION }}"
# Check if payu/dev symlink already exists
if [ -L "${{ env.PAYU_ENVIRONMENT_SYMLINK}}"]; then
if [ -L "${{ env.PAYU_ENVIRONMENT_SYMLINK}}" ]; then
# Get previous version of payu/dev
previous_env_path=$(readlink -f "${{ env.PAYU_ENVIRONMENT_SYMLINK}}")
previous_ver=$(basename "$previous_env_path")
Expand All @@ -171,7 +171,7 @@ jobs:
ln -s ${{ env.PAYU_ENVIRONMENT_LOCATION }} ${{ env.PAYU_ENVIRONMENT_SYMLINK }}
# Setup modulefile symlink
ln -sf ${{ vars.MODULE_LOCATION }}/.common ${{ env.PAYU_MODULE_SYMLINK }}
ln -sf ${{ vars.PRERELEASE_MODULE_LOCATION }}/.common ${{ env.PAYU_MODULE_SYMLINK }}
# Remove old versions of environments
for version in $old_versions; do
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/update-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,28 @@ jobs:
${{ secrets.HOST_DATA }}
private-key: ${{ secrets.SSH_KEY }}

- name: Generate release modulesfiles
run: |
mkdir -p release/modules
sed 's|{{MODULE_LOCATION}}|'"${{ vars.MODULE_LOCATION }}"'|g' modules/.common > release/modules/.common
sed 's|{{APPS_LOCATION}}|'"${{ vars.APPS_LOCATION }}"'|g' modules/env.sh > release/modules/env.sh
chmod +x release/modules/env.sh
- name: Generate pre-release modulesfiles
run: |
mkdir -p prerelease/modules
sed 's|{{MODULE_LOCATION}}|'"${{ vars.PRERELEASE_MODULE_LOCATION }}"'|g' modules/.common > prerelease/modules/.common
sed 's|{{APPS_LOCATION}}|'"${{ vars.PRERELEASE_APPS_LOCATION }}"'|g' modules/env.sh > prerelease/modules/env.sh
chmod +x prerelease/modules/env.sh
- name: Copy modulefiles to Gadi
run: |
# Rsync release modulefiles
rsync -rvp -e 'ssh -i ${{ steps.ssh.outputs.private-key-path }}' \
modules/ \
release/modules/ \
${{ secrets.USER }}@${{ secrets.HOST_DATA }}:${{ vars.MODULE_LOCATION }}
# Rsync development modulefiles
rsync -rvp -e 'ssh -i ${{ steps.ssh.outputs.private-key-path }}' \
prerelease/modules/ \
${{ secrets.USER }}@${{ secrets.HOST_DATA }}:${{ vars.PRERELEASE_MODULE_LOCATION }}
10 changes: 1 addition & 9 deletions modules/.common
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,8 @@ conflict payu
# Name of this module's environment, e.g. payu/VERSION
set payuname [module-info name]

# Check if modulefile is in prerelease folder
if {[string match "/g/data/vk83/prerelease/*" "$ModulesCurrentModulefile"]} {
set is_prerelease true
} else {
set is_prerelease false
}

# Get the environment variables from activate script
set payuenv [exec /bin/env -i \
/g/data/vk83/modules/payu/env.sh $payuname $is_prerelease]
set payuenv [exec /bin/env -i {{MODULE_LOCATION}}/env.sh $payuname]

# Convert the environment into module commands
set lines [split $payuenv '\n']
Expand Down
11 changes: 1 addition & 10 deletions modules/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,5 @@
# Prints the environment variables when activating un-packed environment
export PATH=/usr/bin:/bin

name=$1
is_prerelease=$2

if [ "$is_prerelease" = true ]; then
# Use prerelease location for apps
source /g/data/vk83/prerelease/apps/$name/bin/activate
else
# Use release location for apps
source /g/data/vk83/apps/$name/bin/activate
fi
source {{APPS_LOCATION}}/$1/bin/activate
/bin/env

0 comments on commit 2d5f229

Please sign in to comment.