Skip to content

Commit 7d2e7e6

Browse files
testing post create script
1 parent 1caa510 commit 7d2e7e6

File tree

3 files changed

+62
-29
lines changed

3 files changed

+62
-29
lines changed

.devcontainer/devcontainer.json

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,25 @@
1-
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
2-
// https://github.com/microsoft/vscode-dev-containers/tree/v0.117.1/containers/go
31
{
4-
"name": "devcontainers-ci",
5-
"dockerFile": "Dockerfile",
2+
"name": "Test CI/CD Project",
63
"build": {
7-
"cacheFrom": "ghcr.io/devcontainers/ci-devcontainer:latest"
4+
"dockerfile": "Dockerfile"
85
},
9-
"mounts": [
10-
// Keep command history
11-
"source=devcontainer-build-run-bashhistory,target=/home/vscode/commandhistory",
12-
// Mount host docker socket
13-
"type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock"
14-
],
15-
"postCreateCommand": ".devcontainer/scripts/postCreate.sh",
16-
"remoteUser": "vscode",
6+
"features": {
7+
"ghcr.io/devcontainers/features/git:1": {
8+
"version": "latest"
9+
}
10+
},
11+
"postCreateCommand": "chmod +x scripts/*.sh && scripts/post-create.sh",
12+
"postStartCommand": "chmod +x scripts/*.sh && scripts/post-start.sh",
1713
"customizations": {
1814
"vscode": {
19-
"settings": {
20-
"terminal.integrated.defaultProfile.linux": "bash",
21-
"files.eol": "\n"
22-
},
2315
"extensions": [
24-
"ms-azuretools.vscode-docker",
25-
"yzhang.markdown-all-in-one",
26-
"davidanson.vscode-markdownlint",
27-
"heaths.vscode-guid",
28-
"esbenp.prettier-vscode",
29-
"meganrogge.template-string-converter",
30-
"ms-azure-devops.azure-pipelines"
31-
]
16+
"ms-azuretools.vscode-docker"
17+
],
18+
"settings": {
19+
"terminal.integrated.defaultProfile.linux": "bash"
20+
}
3221
}
3322
},
34-
"features": {
35-
"ghcr.io/devcontainers/features/github-cli:1": "latest"
36-
}
23+
"remoteUser": "root",
24+
"forwardPorts": []
3725
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#!/bin/bash
22

3-
sudo npm install --location=global yarn
3+
# This script runs after the container is created
4+
echo 'Post-create script running (/.devcontainer/scripts)...'
5+
echo "Current folder: $(pwd)"
6+
echo "Current user: $(whoami)"

.github/workflows/post-create.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Test CI/CD with DevContainer Builder
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test-custom-builder:
11+
runs-on: ubuntu-latest
12+
13+
# Add permissions for pushing to GitHub Container Registry
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
22+
# Add authentication step for GitHub Container Registry
23+
- name: Log in to GitHub Container Registry
24+
uses: docker/login-action@v2
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Pre-build dev container image
31+
uses: devcontainers/[email protected]
32+
with:
33+
imageName: ghcr.io/${{ github.repository }}/devcontainer
34+
# cacheFrom: ghcr.io/${{ github.repository }}/devcontainer
35+
# push: always
36+
37+
- name: Run make ci-build in dev container
38+
uses: devcontainers/[email protected]
39+
with:
40+
push: never
41+
runCmd: python3 special_add.py
42+
# ...existing code...

0 commit comments

Comments
 (0)