Build and Run Apptainer #10
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: Build and Run Apptainer | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Apptainer from PPA repository | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y software-properties-common | |
sudo add-apt-repository -y ppa:apptainer/ppa | |
sudo apt-get update | |
sudo apt-get install -y apptainer | |
- name: Build Apptainer image | |
run: | | |
ls -lah | |
apptainer build crpropa.sif crpropa.def | |
# We expect that this action is run in a repository manually, so there is no release or tag available. | |
# Here we create tag from timestamp, and then the release is created with the tag. | |
- name: Create tag | |
id: create_tag | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
const date = new Date(); | |
const timestamp = date.toISOString().replace(/[:.]/g, '-'); | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: `refs/tags/${timestamp}`, | |
sha: context.sha | |
}); | |
return timestamp; | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: crpropa.sif | |
tag_name: ${{ steps.create_tag.outputs.result }} |