Skip to content

Commit

Permalink
extract package name
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorier committed Sep 17, 2024
1 parent 03df401 commit a6149e1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
- uses: actions/checkout@v4
- uses: mochi-hpc/mochi-build-release-action@main
with:
package: mochi-margo
package-name: mochi-margo
build-cache-token: ${{ secrets.GITHUB_TOKEN }}
- uses: mochi-hpc/mochi-build-release-action@main
with:
package-name: mochi-margo
package-version: '@main'
build-cache-token: ${{ secrets.GITHUB_TOKEN }}

33 changes: 29 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ inputs:
description: 'Version or commit hash of the mochi-spack-packages'
required: false
default: 'main'
package:
package-name:
description: 'Package to build'
required: true
required: false
default: 'unspecified'
package-version:
description: 'Version of the package to build (should start with @)'
require: false
default: ''
build-cache-token:
description: 'Token to use to push into the build cache'
required: false
Expand All @@ -26,6 +31,25 @@ runs:
with:
ref: ${{ inputs.spack-version }}

- name: Extract name of calling repository
id: extract_repo_name
if: ${{ inputs.package == 'unspecified' }}
shell: bash
run: |
REPO_NAME=$(echo "${GITHUB_REPOSITORY}" | cut -d'/' -f2)
echo "::set-output name=repo_name::$REPO_NAME"
- name: Find the package name
id: determine_name
shell: bash
run: |
if [[ "${{ inputs.package-name }}" == "unspecified" ]]; then
PACKAGE_NAME="${{ steps.extract_repo_name.outputs.repo_name }}"
else
PACKAGE_NAME="${{ inputs.package-name }}"
fi
echo "::set-output name=package_name::$PACKAGE_NAME"
- name: Add mochi-spack-packages
shell: bash
run: |
Expand All @@ -38,7 +62,8 @@ runs:
- name: Add package to environment
shell: bash
run: |
spack -e "$GITHUB_ACTION_PATH" add ${{ inputs.package }}
spack -e "$GITHUB_ACTION_PATH" add \
${{ steps.determine_name.outputs.package_name }}${{ inputs.package-version }}
- name: Install environment
shell: bash
Expand All @@ -53,4 +78,4 @@ runs:
--oci-username ${{ github.actor }} \
--oci-password "${{ inputs.build-cache-token }}" mochi-buildcache
spack -e "$GITHUB_ACTION_PATH" buildcache push --base-image ubuntu:22.04 \
--unsigned --update-index mochi-buildcache
--unsigned --only dependencies --update-index mochi-buildcache

0 comments on commit a6149e1

Please sign in to comment.