sjiit #52
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: ci | |
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- "v*.*.*" | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
ghcr.io/${{ github.repository_owner }}/nothingtoseehere | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=schedule | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: "{{defaultContext}}:" | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
file: | |
./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
build-push-singularity-container: | |
needs: docker | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
container: | |
image: quay.io/singularity/singularity:v4.1.0 | |
options: --privileged | |
name: Pull-push Singularity Container | |
steps: | |
- name: Check out code for the container builds | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
apk add --no-cache curl | |
VERSION="1.1.0" | |
curl -LO "https://github.com/oras-project/oras/releases/download/v${VERSION}/oras_${VERSION}_linux_amd64.tar.gz" | |
mkdir -p oras-install/ | |
tar -zxf oras_${VERSION}_*.tar.gz -C oras-install/ | |
sudo mv oras-install/oras /usr/local/bin/ | |
rm -rf oras_${VERSION}_*.tar.gz oras-install/ | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/${{ github.repository_owner }}/nothingtoseehere | |
tags: | | |
type=semver,pattern={{version}} | |
type=ref,event=branch | |
type=sha | |
- name: Pull and push Singularity container | |
run: | | |
tags="${{ steps.meta.outputs.tags }}" | |
if [ -n "$tags" ]; then | |
IFS=$'\n' read -r -a tags_array <<< "$tags" | |
echo "Number of tags: ${#tag_array[@]}" | |
echo "$tags" | |
echo ${{ secrets.GITHUB_TOKEN }} | oras login --username ${{ github.repository_owner }} --password-stdin ghcr.io | |
for tag in "${tags_array[@]}"; do | |
echo "processing tag: $tag" | |
singularity pull nothingtoseehere.sif docker://"$tag" | |
oras push ghcr.io/"$tag" --artifact-type application/vnd.acme.rocket.config nothingtoseehere.sif | |
done | |
else | |
echo "No tags found" | |
fi | |
shell: bash |