From bde9194dde90f6150b7ae27b059bf49623796108 Mon Sep 17 00:00:00 2001 From: Dogan Ulus Date: Sat, 30 Mar 2024 19:51:31 +0300 Subject: [PATCH] Initial commit --- .github/workflows/features-release.yml | 48 ++++++++++++++++ .github/workflows/features-test.yml | 57 +++++++++++++++++++ .github/workflows/features-validate.yml | 16 ++++++ features/src/ansible/README.md | 13 +++++ .../src/ansible/devcontainer-feature.json | 9 +++ features/src/ansible/install.sh | 7 +++ 6 files changed, 150 insertions(+) create mode 100644 .github/workflows/features-release.yml create mode 100644 .github/workflows/features-test.yml create mode 100644 .github/workflows/features-validate.yml create mode 100644 features/src/ansible/README.md create mode 100644 features/src/ansible/devcontainer-feature.json create mode 100644 features/src/ansible/install.sh diff --git a/.github/workflows/features-release.yml b/.github/workflows/features-release.yml new file mode 100644 index 0000000..e8ce66e --- /dev/null +++ b/.github/workflows/features-release.yml @@ -0,0 +1,48 @@ +name: "Release dev container features & Generate Documentation" + +on: + workflow_dispatch: + +jobs: + deploy: + if: ${{ github.ref == 'refs/heads/main' }} + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + packages: write + + steps: + - uses: actions/checkout@v4 + + - name: "Publish Features" + uses: devcontainers/action@v1 + with: + publish-features: "true" + base-path-to-features: "./features/src" + generate-docs: "true" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create PR for Documentation + id: push_image_info + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -e + echo "Start." + # Configure git and Push updates + git config --global user.email github-actions[bot]@users.noreply.github.com + git config --global user.name github-actions[bot] + git config pull.rebase false + branch=automated-documentation-update-$GITHUB_RUN_ID + git checkout -b $branch + message='Automated documentation update' + # Add / update and commit + git add */**/README.md + git commit -m 'Automated documentation update [skip ci]' || export NO_UPDATES=true + # Push + if [ "$NO_UPDATES" != "true" ] ; then + git push origin "$branch" + gh pr create --title "$message" --body "$message" + fi diff --git a/.github/workflows/features-test.yml b/.github/workflows/features-test.yml new file mode 100644 index 0000000..ef77dc9 --- /dev/null +++ b/.github/workflows/features-test.yml @@ -0,0 +1,57 @@ +name: "CI - Test Features" +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + test-autogenerated: + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + features: + - ansible + baseImage: + - debian:latest + - ubuntu:latest + + steps: + - uses: actions/checkout@v3 + + - name: "Install latest devcontainer CLI" + run: npm install -g @devcontainers/cli + + - name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'" + run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} . + + test-scenarios: + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + features: + - ansible + + steps: + - uses: actions/checkout@v4 + + - name: "Install latest devcontainer CLI" + run: npm install -g @devcontainers/cli + + - name: "Generating tests for '${{ matrix.features }}' scenarios" + run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated . + + test-global: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v4 + + - name: "Install latest devcontainer CLI" + run: npm install -g @devcontainers/cli + + - name: "Testing global scenarios" + run: devcontainer features test --global-scenarios-only . diff --git a/.github/workflows/features-validate.yml b/.github/workflows/features-validate.yml new file mode 100644 index 0000000..4549f4b --- /dev/null +++ b/.github/workflows/features-validate.yml @@ -0,0 +1,16 @@ +name: "Validate devcontainer-feature.json files" +on: + workflow_dispatch: + pull_request: + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: "Validate devcontainer-feature.json files" + uses: devcontainers/action@v1 + with: + validate-only: "true" + base-path-to-features: "./features/src" diff --git a/features/src/ansible/README.md b/features/src/ansible/README.md new file mode 100644 index 0000000..4552f2d --- /dev/null +++ b/features/src/ansible/README.md @@ -0,0 +1,13 @@ +# Ansible + +An Ansible install feature + +## Example Usage + +```json +"features": { + "ghcr.io/bounverif/devcontainers/features-ansible:0": { + "version": "latest" + } +} +``` \ No newline at end of file diff --git a/features/src/ansible/devcontainer-feature.json b/features/src/ansible/devcontainer-feature.json new file mode 100644 index 0000000..5da162e --- /dev/null +++ b/features/src/ansible/devcontainer-feature.json @@ -0,0 +1,9 @@ +{ + "id": "features-ansible", + "version": "0.1.0", + "name": "Ansible (from source)", + "documentationURL": "https://github.com/bounverif/devcontainers/tree/main/features/src/ansible", + "description": "Install an up-to-date version of Ansible, built from source as needed.", + "options": {}, + "installsAfter": [] +} \ No newline at end of file diff --git a/features/src/ansible/install.sh b/features/src/ansible/install.sh new file mode 100644 index 0000000..dc80bed --- /dev/null +++ b/features/src/ansible/install.sh @@ -0,0 +1,7 @@ +wget -qO- "https://keyserver.ubuntu.com/pks/lookup?fingerprint=on&op=get&search=0x6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367" | gpg --dearmour -o /usr/share/keyrings/ansible-archive-keyring.gpg && \ +echo "deb [signed-by=/usr/share/keyrings/ansible-archive-keyring.gpg] http://ppa.launchpad.net/ansible/ansible/ubuntu jammy main" | tee /etc/apt/sources.list.d/ansible.list && \ +apt-get update +apt-get install -y --no-install-recommends ansible-core +apt-get autoremove -y +apt-get clean -y +rm -rf /var/lib/apt/lists/* \ No newline at end of file