Skip to content

Commit

Permalink
use devcontainer step
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Nov 27, 2024
1 parent 18c6d46 commit 15932dd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
9 changes: 5 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN bash -c "$(curl -sL https://get.containerlab.dev)" -- -v ${CLAB_VERSION}

# Install GitHub CLI directly from the latest release
RUN bash -c 'VERSION=$(curl -s https://api.github.com/repos/cli/cli/releases/latest | \
RUN bash -c 'ARCH=$(uname -m | sed "s/x86_64/amd64/" | sed "s/aarch64/arm64/") && \
VERSION=$(curl -s https://api.github.com/repos/cli/cli/releases/latest | \
grep -oP "\"tag_name\": \"\K[^\"]+") && \
CLEAN_VERSION=${VERSION#v} && \
DOWNLOAD_URL="https://github.com/cli/cli/releases/download/${VERSION}/gh_${CLEAN_VERSION}_linux_amd64.tar.gz" && \
DOWNLOAD_URL="https://github.com/cli/cli/releases/download/${VERSION}/gh_${CLEAN_VERSION}_linux_${ARCH}.tar.gz" && \
curl -L "$DOWNLOAD_URL" | tar xz -C /tmp && \
mv /tmp/gh_${CLEAN_VERSION}_linux_amd64/bin/gh /usr/local/bin/ && \
mv /tmp/gh_${CLEAN_VERSION}_linux_${ARCH}/bin/gh /usr/local/bin/ && \
chmod +x /usr/local/bin/gh && \
rm -rf /tmp/gh_${CLEAN_VERSION}_linux_amd64'
rm -rf /tmp/gh_${CLEAN_VERSION}_linux_${ARCH}'

# Install gNMIc and gNOIc
RUN bash -c "$(curl -sL https://get-gnmic.openconfig.net)" && \
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/zsh/install-zsh-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ git clone --depth 1 https://github.com/z-shell/F-Sy-H.git ${ZSH_CUSTOM:-$HOME/.o
### Shell completions
###
# generate containerlab completions
containerlab completion zsh > "/home/vscode/.oh-my-zsh/custom/plugins/zsh-autocomplete/Completions/_containerlab"
/usr/bin/containerlab completion zsh > "/home/vscode/.oh-my-zsh/custom/plugins/zsh-autocomplete/Completions/_containerlab"
# add clab alias to the completions
sed -i 's/compdef _containerlab containerlab/compdef _containerlab containerlab clab/g' /home/vscode/.oh-my-zsh/custom/plugins/zsh-autocomplete/Completions/_containerlab
# generate gnmic completions
gnmic completion zsh > "/home/vscode/.oh-my-zsh/custom/plugins/zsh-autocomplete/Completions/_gnmic"
# generate gnoic completions
gnoic completion zsh > "/home/vscode/.oh-my-zsh/custom/plugins/zsh-autocomplete/Completions/_gnoic"
# generate gh
# gh completion -s zsh > "/home/vscode/.oh-my-zsh/custom/plugins/zsh-autocomplete/Completions/_gh"
gh completion -s zsh > "/home/vscode/.oh-my-zsh/custom/plugins/zsh-autocomplete/Completions/_gh"
19 changes: 13 additions & 6 deletions .github/workflows/build-devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/clab-devcontainer
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=ref,event=branch
Expand All @@ -50,12 +50,19 @@ jobs:
# manually set tag
type=raw,value=${{ inputs.tag }}
- name: Extract tags
id: extract-tags
run: |
TAGS=$(echo '${{ steps.meta.outputs.tags }}' | awk -F: '{print $2}' | paste -sd "," -)
echo "TAGS=$TAGS" >> $GITHUB_OUTPUT
shell: bash

- name: Build dev container image
uses: docker/build-push-action@v6
uses: devcontainers/[email protected]
env:
CLAB_VERSION: ${{ inputs.clab_version }}
with:
file: .devcontainer/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
push: true
platforms: linux/amd64,linux/arm64
imageName: ghcr.io/${{ github.repository }}/clab-devcontainer
imageTag: ${{ steps.extract-tags.outputs.tags }}
push: always
platform: linux/amd64,linux/arm64

0 comments on commit 15932dd

Please sign in to comment.