From 7d2e7e64f02db79af84cda9396831cbfcb13910c Mon Sep 17 00:00:00 2001 From: sireesha Date: Fri, 4 Jul 2025 13:22:55 +0530 Subject: [PATCH] testing post create script --- .devcontainer/devcontainer.json | 44 +++++++++++------------------ .devcontainer/scripts/postCreate.sh | 5 +++- .github/workflows/post-create.yml | 42 +++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/post-create.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e629bb760..42eafee90 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,37 +1,25 @@ -// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.117.1/containers/go { - "name": "devcontainers-ci", - "dockerFile": "Dockerfile", + "name": "Test CI/CD Project", "build": { - "cacheFrom": "ghcr.io/devcontainers/ci-devcontainer:latest" + "dockerfile": "Dockerfile" }, - "mounts": [ - // Keep command history - "source=devcontainer-build-run-bashhistory,target=/home/vscode/commandhistory", - // Mount host docker socket - "type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock" - ], - "postCreateCommand": ".devcontainer/scripts/postCreate.sh", - "remoteUser": "vscode", + "features": { + "ghcr.io/devcontainers/features/git:1": { + "version": "latest" + } + }, + "postCreateCommand": "chmod +x scripts/*.sh && scripts/post-create.sh", + "postStartCommand": "chmod +x scripts/*.sh && scripts/post-start.sh", "customizations": { "vscode": { - "settings": { - "terminal.integrated.defaultProfile.linux": "bash", - "files.eol": "\n" - }, "extensions": [ - "ms-azuretools.vscode-docker", - "yzhang.markdown-all-in-one", - "davidanson.vscode-markdownlint", - "heaths.vscode-guid", - "esbenp.prettier-vscode", - "meganrogge.template-string-converter", - "ms-azure-devops.azure-pipelines" - ] + "ms-azuretools.vscode-docker" + ], + "settings": { + "terminal.integrated.defaultProfile.linux": "bash" + } } }, - "features": { - "ghcr.io/devcontainers/features/github-cli:1": "latest" - } + "remoteUser": "root", + "forwardPorts": [] } \ No newline at end of file diff --git a/.devcontainer/scripts/postCreate.sh b/.devcontainer/scripts/postCreate.sh index 4b416a775..7a544c670 100755 --- a/.devcontainer/scripts/postCreate.sh +++ b/.devcontainer/scripts/postCreate.sh @@ -1,3 +1,6 @@ #!/bin/bash -sudo npm install --location=global yarn +# This script runs after the container is created +echo 'Post-create script running (/.devcontainer/scripts)...' +echo "Current folder: $(pwd)" +echo "Current user: $(whoami)" diff --git a/.github/workflows/post-create.yml b/.github/workflows/post-create.yml new file mode 100644 index 000000000..48ba3e5cb --- /dev/null +++ b/.github/workflows/post-create.yml @@ -0,0 +1,42 @@ +name: Test CI/CD with DevContainer Builder + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test-custom-builder: + runs-on: ubuntu-latest + + # Add permissions for pushing to GitHub Container Registry + permissions: + contents: read + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + # Add authentication step for GitHub Container Registry + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pre-build dev container image + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/${{ github.repository }}/devcontainer + # cacheFrom: ghcr.io/${{ github.repository }}/devcontainer + # push: always + + - name: Run make ci-build in dev container + uses: devcontainers/ci@v0.3 + with: + push: never + runCmd: python3 special_add.py + # ...existing code... \ No newline at end of file