Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/publish-feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish Devcontainer Feature

on:
release:
types: [created]

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5

- name: Install Devcontainer CLI
run: npm install -g @devcontainers/cli

- name: Login to GitHub Container Registry
run: echo "${{ secrets.WRITE_PACKAGES_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Add version to environment
run: |
VERSION="${{ github.ref_name }}"
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Add version to devcontainer-feature.json
run: |
jq --arg VERSION "${{ env.VERSION }}" '.version = $VERSION' src/cvmfs/devcontainer-feature.json > tmp.json
mv tmp.json src/cvmfs/devcontainer-feature.json

- name: Publish Devcontainer Feature
run: devcontainer features publish --namespace ${{ github.actor }}/${{ github.repository }} .
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is not really a way to build the feature locally, build a dev container locally, and test it locally (which is weird; it's just docker stuff with a wrapper).


- name: Build Devcontainer Feature
run: devcontainer build --workspace-folder . --image-name test-cvmfs-feature --additional-features ghcr.io/${{ github.actor }}/${{ github.repository }}/cvmfs:${{ env.VERSION }}
39 changes: 39 additions & 0 deletions README.devcontainer-feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# CVMFS Devcontainer Feature

This directory contains a devcontainer feature for installing and configuring the CVMFS client. The definition is located in the top-level directory to allow reuse of the GitHub Actions scripts.

## Publishing to GHCR

This feature is intended to be published to the GitHub Container Registry (GHCR) to be easily reusable by other projects.

### Manual Publishing

1. **Install the Devcontainer CLI:**
```bash
npm install -g @devcontainers/cli
```

2. **Create a Personal Access Token (PAT):**
* Go to GitHub **Settings** > **Developer settings** > **Personal access tokens** > **Tokens (classic)**.
* Generate a new token with the `write:packages` scope.
* Export the token as an environment variable:
```bash
export WRITE_PACKAGES_TOKEN=your-personal-access-token
```

3. **Log in to GHCR:**
```bash
echo $WRITE_PACKAGES_TOKEN | docker login ghcr.io -u your-github-username --password-stdin
```

4. **Publish the Feature:**
Run the following command from the root of this repository. The namespace should match the GitHub organization (`cvmfs-contrib`).
```bash
devcontainer features publish --namespace cvmfs-contrib/github-action-cvmfs .
```

### Automated Publishing

This repository is configured with a GitHub Actions workflow to automate this process. When a new release is published on GitHub, the workflow will automatically build and publish the feature to GHCR.

For this to work, the `WRITE_PACKAGES_TOKEN` secret (a Personal Access Token with `write:packages` scope) must be configured in the repository's **Settings > Secrets and variables > Actions**.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ This GitHub Action is only expected to work in workflows that [run on](https://d

`windows` targets are not supported.

## Devcontainer Usage

This repository provide a Dev Container Feature to enable CernVM-FS in your Dev Containers. To use it, open this repository in a devcontainer-compatible editor like VS Code with the Dev Containers extension.

For example, you can add the following to your `devcontainer.json` to use this feature:
```json
{
"name": "CVMFS Action Dev",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/cvmfs-contrib/github-action-cvmfs/cvmfs": {
"CVMFS_REPOSITORIES": "sft.cern.ch"
}
}
}
```

## Use With Docker

In case your workflow uses docker containers, the cvmfs directory can be mounted inside the container by using the flag `-v /cvmfs:/cvmfs:shared`.
24 changes: 24 additions & 0 deletions devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "CVMFS",
"id": "cvmfs",
"version": "0.0.0",
"description": "Installs CVMFS client",
"options": {
"CVMFS_REPOSITORIES": {
"type": "string",
"default": "sft.cern.ch",
"description": "Comma-separated list of fully qualified repository names that shall be mountable under /cvmfs"
},
"CVMFS_CONFIG_PACKAGE": {
"type": "string",
"default": "cvmfs-config-default",
"description": "URL to the cvmfs config package to install"
},
"CVMFS_HTTP_PROXY": {
"type": "string",
"default": "DIRECT",
"description": "Chain of HTTP proxy groups used by CernVM-FS. Defaults to DIRECT."
}
},
"entrypoint": "install-cvmfs-linux.sh"
}
11 changes: 10 additions & 1 deletion setup-cvmfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,16 @@ fi
echo "::endgroup::"


if [ "$(uname)" == "Darwin" ]; then
if [ "$(uname)" == "Linux" ]; then
# Mount CVMFS repositories (in case no autofs)
for repo in $(echo ${CVMFS_REPOSITORIES} | sed "s/,/ /g")
do
if [ ! -d /cvmfs/${repo} ]; then
sudo mount -t cvmfs ${repo} /cvmfs/${repo}
fi
done
elif [ "$(uname)" == "Darwin" ]; then
# Mount CVMFS repositories (no autofs available)
for repo in $(echo ${CVMFS_REPOSITORIES} | sed "s/,/ /g")
do
mkdir -p /Users/Shared/cvmfs/${repo}
Expand Down
Loading