From 90f2fae3dfe164d477e440570d3a4b10894a7975 Mon Sep 17 00:00:00 2001 From: Kevin Mack Date: Fri, 7 Jun 2024 19:51:57 +0000 Subject: [PATCH] Adding workflow file --- .github/workflows/feature.yml | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/feature.yml diff --git a/.github/workflows/feature.yml b/.github/workflows/feature.yml new file mode 100644 index 0000000..f8c9d59 --- /dev/null +++ b/.github/workflows/feature.yml @@ -0,0 +1,69 @@ +name: k3s-on-host + +on: + push: + branches: [ main ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v2 + + + - name: Install devcontainer cli + run: | + npm install -g @devcontainers/cli + devcontainer --version + printenv + + - name: Install oras + run: | + curl -LO https://github.com/oras-project/oras/releases/download/v0.16.0/oras_0.16.0_linux_amd64.tar.gz + mkdir -p oras-install/ + tar -zxf oras_0.16.0_*.tar.gz -C oras-install/ + mv oras-install/oras /usr/local/bin/ + rm -rf oras_0.16.0_*.tar.gz oras-install/ + + - name: Building Feature Package + run: | + mkdir -p ./output + rm ./output/* + echo "devcontainer features package --force-clean-output-folder ./.devcontainer/features --output-folder ./output" + devcontainer features package --force-clean-output-folder ./.devcontainer/features --output-folder ./output + sub_exit_code=${PIPESTATUS[0]} + if [[ $sub_exit_code -gt 0 ]]; then + echo "Previous step failed. Troubleshoot" + exit 1 + fi + + - name: Pushing Feature Package + run: | + echo "oras push ${{ github.repository }}:latest --config /dev/null:application/vnd.devcontainers ./output/devcontainer-feature-k3s-on-host.tgz:application/vnd.devcontainers.layer.v1+tar" + oras push ${{ github.repository }}/$(FEATURE_NAME):latest \ + --config /dev/null:application/vnd.devcontainers \ + ./output/devcontainer-feature-k3s-on-host.tgz:application/vnd.devcontainers.layer.v1+tar + sub_exit_code=${PIPESTATUS[0]} + if [[ $sub_exit_code -gt 0 ]]; then + echo "Previous step failed. Troubleshoot" + exit 1 + fi + + echo "oras push ${{ github.repository }}:latest --config /dev/null:application/vnd.devcontainers ./output/$(FEATURE_DEVCONTAINER_COLLECTION_FILE_NAME):application/vnd.devcontainers.collection.layer.v1+json" + oras push ${{ github.repository }}:latest \ + --config /dev/null:application/vnd.devcontainers \ + ./output/$(FEATURE_DEVCONTAINER_COLLECTION_FILE_NAME):application/vnd.devcontainers.collection.layer.v1+json + sub_exit_code=${PIPESTATUS[0]} + if [[ $sub_exit_code -gt 0 ]]; then + echo "Previous step failed. Troubleshoot" + exit 1 + fi