Update common modulefiles on Gadi #15
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: Update common modulefiles on Gadi | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- 'modules/**' | |
jobs: | |
get-deployment-sites: | |
name: Get Deployment Sites | |
runs-on: ubuntu-latest | |
outputs: | |
deployment-sites: ${{ steps.get-deployment-sites.outputs.deployment-sites }} | |
steps: | |
- name: Checkout config | |
uses: actions/checkout@v4 | |
- name: Get sites | |
id: get-deployment-sites | |
run: echo "deployment-sites=$(jq --compact-output '.sites' ./config/deployment-sites.json)" >> $GITHUB_OUTPUT | |
deploy: | |
runs-on: ubuntu-latest | |
needs: get-deployment-sites | |
strategy: | |
fail-fast: false | |
matrix: | |
deployment-sites: ${{ fromJson(needs.get-deployment-sites.outputs.deployment-sites) }} | |
environment: ${{ matrix.deployment-sites }} | |
env: | |
INPUT_DIR: modules | |
OUTPUT_DIR: release/modules | |
OUTPUT_DIR_PRERELEASE: prerelease/modules | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: access-nri/actions/.github/actions/setup-ssh@main | |
id: ssh | |
with: | |
hosts: | | |
${{ secrets.HOST_DATA }} | |
private-key: ${{ secrets.SSH_KEY }} | |
- name: Set deployment directories | |
run: | | |
echo "MODULE_DEPLOYMENT_DIR=${{ vars.ROOT_DIR }}/${{vars.MODULES_DIR}}/${{vars.MODULE_NAME}}" >> $GITHUB_ENV | |
echo "APP_DEPLOYMENT_DIR=${{ vars.ROOT_DIR }}/${{vars.APPS_DIR}}/${{vars.MODULE_NAME}}" >> $GITHUB_ENV | |
echo "MODULE_DEPLOYMENT_DIR_PRERELEASE=${{ vars.ROOT_DIR_PRERELEASE }}/${{vars.MODULES_DIR}}/${{vars.MODULE_NAME}}" >> $GITHUB_ENV | |
echo "APP_DEPLOYMENT_DIR_PRERELEASE=${{ vars.ROOT_DIR_PRERELEASE }}/${{vars.APPS_DIR}}/${{vars.MODULE_NAME}}" >> $GITHUB_ENV | |
- name: Generate release modulesfiles | |
run: | | |
mkdir -p ${{ env.OUTPUT_DIR }} | |
sed "s|{{MODULE_DIR}}|$MODULE_DEPLOYMENT_DIR|g" ${{env.INPUT_DIR}}/.common > ${{env.OUTPUT_DIR}}/.common | |
sed 's|{{APPS_DIR}}|$APP_DEPLOYMENT_DIR|g' ${{env.INPUT_DIR}}/env.sh > ${{env.OUTPUT_DIR}}/env.sh | |
chmod +x ${{ env.OUTPUT_DIR }}/env.sh | |
- name: Copy release modulefiles to Gadi | |
run: | | |
# Create module deployment directory | |
ssh ${{ secrets.USER }}@${{ secrets.HOST_DATA }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<EOT | |
mkdir -p "$MODULE_DEPLOYMENT_DIR" | |
EOT | |
if [ $? -ne 0 ]; then | |
echo "Failed to create module deployment release directory" | |
exit 1 | |
fi | |
# Rsync release modulefiles | |
rsync -rvp -e 'ssh -i ${{ steps.ssh.outputs.private-key-path }}' \ | |
${{ env.OUTPUT_DIR }}/ \ | |
${{ secrets.USER }}@${{ secrets.HOST_DATA }}:${MODULE_DEPLOYMENT_DIR} | |
- name: Generate prerelease modulesfiles | |
run: | | |
mkdir -p ${{ env.OUTPUT_DIR_PRERELEASE }} | |
sed "s|{{MODULE_DIR}}|$MODULE_DEPLOYMENT_DIR_PRERELEASE|g" ${{env.INPUT_DIR}}/.common > ${{env.OUTPUT_DIR_PRERELEASE}}/.common | |
sed 's|{{APPS_DIR}}|$APP_DEPLOYMENT_DIR_PRERELEASE|g' ${{env.INPUT_DIR}}/env.sh > ${{env.OUTPUT_DIR_PRERELEASE}}/env.sh | |
chmod +x ${{ env.OUTPUT_DIR_PRERELEASE }}/env.sh | |
- name: Copy prerelease modulefiles to Gadi | |
run: | | |
# Create module deployment directory | |
ssh ${{ secrets.USER }}@${{ secrets.HOST_DATA }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<EOT | |
mkdir -p "$MODULE_DEPLOYMENT_DIR_PRERELEASE" | |
EOT | |
if [ $? -ne 0 ]; then | |
echo "Failed to create module deployment prerelease directory" | |
exit 1 | |
fi | |
# Rsync prerelease modulefiles | |
rsync -rvp -e 'ssh -i ${{ steps.ssh.outputs.private-key-path }}' \ | |
${{ env.OUTPUT_DIR_PRERELEASE }}/ \ | |
${{ secrets.USER }}@${{ secrets.HOST_DATA }}:${MODULE_DEPLOYMENT_DIR_PRERELEASE} |