From 99c2e33c331bbd102e013bd81b38d9e4788ce174 Mon Sep 17 00:00:00 2001 From: Amin Al Ali Al Darwish Date: Wed, 3 Sep 2025 17:10:41 +0400 Subject: [PATCH] Update GitHub workflows to use new showcase-code-server folder path --- .../templates/showcase-code-server/README.md | 331 ++++++++++-------- .../showcase-code-server/bunnyshell.yaml | 17 +- .../showcase-code-server/bunnyshell.yaml.old | 124 +++++++ .../showcase-code-server/template.yaml | 26 +- .github/workflows/README.md | 76 ++++ .../update-code-server-version-frequent.yml | 124 +++++++ .../workflows/update-code-server-version.yml | 127 +++++++ 7 files changed, 644 insertions(+), 181 deletions(-) create mode 100644 .bunnyshell/templates/showcase-code-server/bunnyshell.yaml.old create mode 100644 .github/workflows/README.md create mode 100644 .github/workflows/update-code-server-version-frequent.yml create mode 100644 .github/workflows/update-code-server-version.yml diff --git a/.bunnyshell/templates/showcase-code-server/README.md b/.bunnyshell/templates/showcase-code-server/README.md index 31d195cc..eca92b47 100644 --- a/.bunnyshell/templates/showcase-code-server/README.md +++ b/.bunnyshell/templates/showcase-code-server/README.md @@ -1,152 +1,189 @@ -# Integrating VS Code as a Sidecar Container using Bunnyshell -This documentation provides a step-by-step guide to integrate VS Code as a sidecar container for remote development using Bunnyshell. The provided `bunnyshell.yaml` template showcases how to achieve this setup effectively. - -## Pre-Requisites - -If your application uses a specified UID/GID please adjust the PUID and GUID template variables to reflect the id of the user being created to avoid permission issues. - -### Understanding the Need for PUID and GUID - -When mounting volumes across containers, permission issues can arise between the main and sidecar containers. Specifying the user PUID and group PGID ensures consistency and avoids these issues. Use the command `id your_user` to find your user and group IDs. - -## Template Variables Explained - -### Crucial Lines in the `bunnyshell.yaml` - -1. **Exposing the Port for the Sidecar Container:** - - ```yaml - dockerCompose: - ports: - - '8080:8080' # main app port - - '8443:8443' # code-server port - ``` - -2. **Defining the Sidecar Container:** - - ```yaml - dockerCompose: - pod: - sidecar_containers: - - - from: code-server - name: sidecar-code-server - shared_paths: - - - path: /config/workspace - target: - path: /path/to/src/in/main/container - container: '@parent' - initial_contents: '@target' - ``` - - - `shared_paths[0].path`: The default workspace opened in the IDE. - - `shared_paths[0].target.path`: The path where the source code is in the main pod. - -3. **Generating the Hostname for the Code Server Sidecar:** - - ```yaml - hosts: - ... # host for main application - - - hostname: '{{template.vars.CODE_SERVER_HOST}}' - path: / - servicePort: '8443' - ``` - -4. **Code-Server Environment Variables:** - - Refer to [Code-Server Environment Variables Documentation](https://docs.linuxserver.io/images/docker-code-server/#environment-variables-from-files-docker-secrets). - - ```yaml - dockerCompose: - environment: - DEFAULT_WORKSPACE: '/config/workspace' - HASHED_PASSWORD: {{template.vars.HASHED_PASSWORD}} - PASSWORD: {{template.vars.PASSWORD}} - PGID: '{{template.vars.PGID}}' - PROXY_DOMAIN: {{template.vars.PROXY_DOMAIN}} - PUID: '{{template.vars.PUID}}' - SUDO_PASSWORD: {{template.vars.SUDO_PASSWORD}} - SUDO_PASSWORD_HASH: {{template.vars.SUDO_PASSWORD_HASH}} - TZ: {{ template.vars.TZ }} - ``` - - - `PUID=1000`: UserID. - - `PGID=1000`: GroupID. - - `TZ=Etc/UTC`: Specify a timezone. - - `PASSWORD=password`: Optional web GUI password. - - `HASHED_PASSWORD=`: Optional hashed web GUI password. - - `SUDO_PASSWORD=password`: Optional sudo password. - - `SUDO_PASSWORD_HASH=`: Optionally set sudo password via hash. - - `PROXY_DOMAIN=code-server.my.domain`: Optional proxy domain. - - `DEFAULT_WORKSPACE=/config/workspace`: Default workspace directory. - -## Example `bunnyshell.yaml` File - -Below is the full `bunnyshell.yaml` configuration template: +# VS Code Sidecar Integration with Bunnyshell + +This template demonstrates how to integrate VS Code as a sidecar container for remote development using Bunnyshell. It provides a complete development environment with a full-stack application (frontend, backend, database) and VS Code accessible through a web browser. +It provides: +- **Frontend Application**: React-based web application +- **Backend API**: Node.js backend service +- **Database**: PostgreSQL database +- **VS Code**: Web-based IDE accessible from anywhere +- **Shared Workspace**: Code accessible from both the main app and VS Code + +# πŸš€ TL;DR + +1. **Deploy the template** using Bunnyshell +2. **Access your application** at `frontend-{your-domain}` and `backend-{your-domain}` +3. **Open VS Code** at `code-server-{your-domain}` with the password: `password` + +## πŸš€ Usage Workflow + +``` +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ 1. Deploy │───►│ 2. Access │───►│ 3. Login to β”‚ +β”‚ Environment β”‚ β”‚ VS Code β”‚ β”‚ VS Code β”‚ +β”‚ via Bunnyshellβ”‚ β”‚ code-server- β”‚ β”‚ with Password β”‚ +β”‚ β”‚ β”‚ {domain} β”‚ β”‚ β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ 6. Changes │◄───│ 5. Start │◄───│ 4. Open β”‚ +β”‚ Auto-Sync β”‚ β”‚ Coding in β”‚ β”‚ Shared β”‚ +β”‚ Between β”‚ β”‚ Workspace β”‚ β”‚ Workspace β”‚ +β”‚ Containers β”‚ β”‚ β”‚ β”‚ β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +## πŸ—οΈ Architecture Overview + +``` + β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ Bunnyshell Environment β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ β”‚ β”‚ β”‚ + β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ Frontend β”‚ β”‚ VS Code β”‚ β”‚ Backend β”‚ β”‚ Database β”‚ + β”‚ Container β”‚ β”‚ Sidecar β”‚ β”‚ Container β”‚ β”‚ Container β”‚ + β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ + β”‚ β€’ React App β”‚ β”‚ β€’ Web IDE β”‚ β”‚ β€’ Node.js API β”‚ β”‚ β€’ PostgreSQL β”‚ + β”‚ β€’ Port: 8080 β”‚ β”‚ β€’ Port: 8443 β”‚ β”‚ β€’ Port: 3080 β”‚ β”‚ β€’ Port: 5432 β”‚ + β”‚ β€’ Host: frontendβ”‚ β”‚ β€’ Host: code- β”‚ β”‚ β€’ Host: backend β”‚ β”‚ β€’ Internal β”‚ + β”‚ -{domain} β”‚ β”‚ server-{domain}β”‚ β”‚ -{domain} β”‚ β”‚ access only β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ β”‚ + β”‚ β”‚ + β”‚ β”‚ + β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ β”‚ Shared Workspace β”‚ + └───│ /cs_workspace β”‚ + β”‚ (Auto-sync) β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` +## πŸ“ File Structure + +``` +cs_workspace/ # Shared workspace (accessible from both containers) +β”œβ”€β”€ frontend/ # React application source +β”‚ β”œβ”€β”€ src/ # Source code directory +β”‚ β”œβ”€β”€ public/ # Public assets +β”‚ β”œβ”€β”€ package.json # Dependencies and scripts +β”‚ └── Dockerfile # Frontend container build +β”œβ”€β”€ backend/ # Node.js API source +β”‚ β”œβ”€β”€ src/ # API source code +β”‚ β”œβ”€β”€ routes/ # API endpoints +β”‚ β”œβ”€β”€ models/ # Database models +β”‚ β”œβ”€β”€ package.json # Backend dependencies +β”‚ └── Dockerfile # Backend container build +└── README.md # Project documentation +``` + +# βš™οΈ Configuration + +## Template Variables + +| Variable | Description | Default | Required | +|----------|-------------|---------|----------| +| `PASSWORD` | VS Code web interface password | `password` | Yes | +| `SUDO_PASSWORD` | Sudo password for container | `password` | Yes | + +## Environment Variables + +| Variable | Description | Default | +|----------|-------------|---------| +| `HASHED_PASSWORD` | Hashed version of password | `` | +| `PUID` | User ID for container permissions | `0` | +| `PGID` | Group ID for container permissions | `0` | +| `SUDO_PASSWORD_HASH` | Hashed sudo password | `` | +| `PROXY_DOMAIN` | Custom proxy domain | `` | +| `TZ` | Timezone setting | `Etc/UTC` | + +## Port Configuration + +- **Frontend**: `8080` (main application) +- **Backend**: `3080` (API service) +- **Database**: `5432` (PostgreSQL) +- **VS Code**: `8443` (web IDE) + +## πŸ”§ Key Configuration Sections + +### 1. Sidecar Container Definition + +```yaml +pod: + sidecar_containers: + - from: code-server + name: sidecar-code-server + shared_paths: + - path: /cs_workspace + target: + path: /usr/src/app + container: '@parent' + initial_contents: '@target' +``` + +**What this does:** +- Creates a VS Code sidecar container +- Shares the `/cs_workspace` directory between containers +- Maps to `/usr/src/app` in the main application container +- Initializes with the target container's contents + +### 2. Port Exposure + +```yaml +ports: + - '8080:8080' # Frontend app + - '8443:8443' # VS Code sidecar +``` + +**Important:** Both ports must be exposed on the main application to make the sidecar accessible. + +### 3. VS Code Container Configuration ```yaml -kind: Environment +kind: SidecarContainer name: code-server -type: primary -templateVariables: - CODE_SERVER_HOST: code-server-{{env.base_domain}} - HASHED_PASSWORD: '' - PASSWORD: password - PGID: '1000' - PROXY_DOMAIN: '' - PUID: '1000' - SUDO_PASSWORD: password - SUDO_PASSWORD_HASH: '' - TZ: Etc/UTC -components: - - - kind: Application - name: sample-app - gitRepo: 'https://github.com/githubuser/example.git' - gitBranch: master - gitApplicationPath: / - dockerCompose: - ... - ports: - - ... # App Port - - '8443:8443' - pod: - sidecar_containers: - - - from: code-server - name: sidecar-code-server - shared_paths: - - - path: /config/workspace - target: - path: /usr/share/nginx/html - container: '@parent' - initial_contents: '@target' - hosts: - - ... # main app host - - - hostname: '{{template.vars.CODE_SERVER_HOST}}' - path: / - servicePort: '8443' - - - kind: SidecarContainer - name: code-server - dockerCompose: - image: 'lscr.io/linuxserver/code-server:latest' - environment: - DEFAULT_WORKSPACE: '/config/workspace' - HASHED_PASSWORD: {{template.vars.HASHED_PASSWORD}} - PASSWORD: {{template.vars.PASSWORD}} - PGID: '{{template.vars.PGID}}' - PROXY_DOMAIN: {{template.vars.PROXY_DOMAIN}} - PUID: '{{template.vars.PUID}}' - SUDO_PASSWORD: '{{template.vars.SUDO_PASSWORD}}' - SUDO_PASSWORD_HASH: '{{template.vars.SUDO_PASSWORD_HASH}}' - TZ: '{{template.vars.TZ}}' - ports: - - '8443:8443' +dockerCompose: + image: 'lscr.io/linuxserver/code-server:latest' + environment: + DEFAULT_WORKSPACE: /cs_workspace + PASSWORD: '{{template.vars.PASSWORD}}' + # ... other environment variables + ports: + - '8443:8443' ``` -This template facilitates the integration of VS Code as a sidecar container for remote development, ensuring a seamless and efficient development workflow. Adjust the provided `bunnyshell.yaml` and Dockerfile snippets to suit your application's needs. For further customization, refer to the [Code-Server Environment Variables Documentation](https://docs.linuxserver.io/images/docker-code-server/#environment-variables-from-files-docker-secrets). \ No newline at end of file +# πŸ” Security Considerations + +## Default Credentials +- **VS Code Password**: `password` (change this in production!) +- **Database Password**: `need-to-replace` (must be changed!) + +## Permission Management +When using custom UID/GID: +1. Set appropriate `PUID` and `PGID` values +2. Ensure consistency across containers +3. Use `id your_user` command to find your user/group IDs + +# πŸ” Troubleshooting + +## Common Issues + +**Permission Errors:** +- Ensure `PUID` and `PGID` match your user/group IDs +- Check that shared paths have correct permissions + +# πŸ“š Additional Resources + +- [Code-Server Environment Variables](https://docs.linuxserver.io/images/docker-code-server/#environment-variables-from-files-docker-secrets) +- [Bunnyshell Documentation](https://docs.bunnyshell.com/) + +# 🀝 Contributing + +This template is part of the Bunnyshell template collection. Feel free to: +- Report issues +- Suggest improvements +- Submit pull requests + +# πŸ“„ License + +This template is provided as-is for educational and development purposes. \ No newline at end of file diff --git a/.bunnyshell/templates/showcase-code-server/bunnyshell.yaml b/.bunnyshell/templates/showcase-code-server/bunnyshell.yaml index aaab6c02..588d02a6 100644 --- a/.bunnyshell/templates/showcase-code-server/bunnyshell.yaml +++ b/.bunnyshell/templates/showcase-code-server/bunnyshell.yaml @@ -2,13 +2,13 @@ kind: Environment name: code-server type: primary templateVariables: - CODE_SERVER_HOST: 'code-server-{{env.base_domain}}' - HASHED_PASSWORD: '' PASSWORD: password + SUDO_PASSWORD: password +environmentVariables: + HASHED_PASSWORD: '' PGID: '0' PROXY_DOMAIN: '' PUID: '0' - SUDO_PASSWORD: password SUDO_PASSWORD_HASH: '' TZ: Etc/UTC components: @@ -46,24 +46,19 @@ components: path: / servicePort: 8080 - - hostname: '{{template.vars.CODE_SERVER_HOST}}' + hostname: 'code-server-{{env.base_domain}}' path: / servicePort: 8443 - kind: SidecarContainer name: code-server dockerCompose: - image: 'lscr.io/linuxserver/code-server:4.90.3' + image: 'lscr.io/linuxserver/code-server:latest' environment: DEFAULT_WORKSPACE: /cs_workspace - HASHED_PASSWORD: '{{template.vars.HASHED_PASSWORD}}' + CODE_SERVER_HOST: '0.0.0.0' PASSWORD: '{{template.vars.PASSWORD}}' - PGID: '{{template.vars.PGID}}' - PROXY_DOMAIN: '{{template.vars.PROXY_DOMAIN}}' - PUID: '{{template.vars.PUID}}' SUDO_PASSWORD: '{{template.vars.SUDO_PASSWORD}}' - SUDO_PASSWORD_HASH: '{{template.vars.SUDO_PASSWORD_HASH}}' - TZ: '{{ template.vars.TZ }}' ports: - '8443:8443' volumes: diff --git a/.bunnyshell/templates/showcase-code-server/bunnyshell.yaml.old b/.bunnyshell/templates/showcase-code-server/bunnyshell.yaml.old new file mode 100644 index 00000000..aaab6c02 --- /dev/null +++ b/.bunnyshell/templates/showcase-code-server/bunnyshell.yaml.old @@ -0,0 +1,124 @@ +kind: Environment +name: code-server +type: primary +templateVariables: + CODE_SERVER_HOST: 'code-server-{{env.base_domain}}' + HASHED_PASSWORD: '' + PASSWORD: password + PGID: '0' + PROXY_DOMAIN: '' + PUID: '0' + SUDO_PASSWORD: password + SUDO_PASSWORD_HASH: '' + TZ: Etc/UTC +components: + - + kind: Application + name: frontend + gitRepo: 'https://github.com/bunnyshell/demo-books.git' + gitBranch: master + gitApplicationPath: frontend + dockerCompose: + build: + context: ./frontend + dockerfile: Dockerfile + target: dev + args: + REACT_APP_BASE_API: 'https://{{ components.backend.ingress.hosts[0] }}' + ports: + - '8080:8080' + - '8443:8443' + pod: + sidecar_containers: + - + from: code-server + name: sidecar-code-server + shared_paths: + - + path: /cs_workspace + target: + path: /usr/src/app + container: '@parent' + initial_contents: '@target' + hosts: + - + hostname: 'frontend-{{ env.base_domain }}' + path: / + servicePort: 8080 + - + hostname: '{{template.vars.CODE_SERVER_HOST}}' + path: / + servicePort: 8443 + - + kind: SidecarContainer + name: code-server + dockerCompose: + image: 'lscr.io/linuxserver/code-server:4.90.3' + environment: + DEFAULT_WORKSPACE: /cs_workspace + HASHED_PASSWORD: '{{template.vars.HASHED_PASSWORD}}' + PASSWORD: '{{template.vars.PASSWORD}}' + PGID: '{{template.vars.PGID}}' + PROXY_DOMAIN: '{{template.vars.PROXY_DOMAIN}}' + PUID: '{{template.vars.PUID}}' + SUDO_PASSWORD: '{{template.vars.SUDO_PASSWORD}}' + SUDO_PASSWORD_HASH: '{{template.vars.SUDO_PASSWORD_HASH}}' + TZ: '{{ template.vars.TZ }}' + ports: + - '8443:8443' + volumes: + - + name: code-server-data + mount: /config + subPath: '' + - + kind: Application + name: backend + gitRepo: 'https://github.com/bunnyshell/demo-books.git' + gitBranch: master + gitApplicationPath: backend + dockerCompose: + build: + context: ./backend + dockerfile: Dockerfile + target: prod + environment: + FRONTEND_URL: 'https://{{ components.frontend.ingress.hosts[0].hostname }}' + POSTGRES_DB: bunny_books + POSTGRES_HOST: db + POSTGRES_PASSWORD: need-to-replace + POSTGRES_USER: postgres + ports: + - '3080:3080' + hosts: + - + hostname: 'backend-{{ env.base_domain }}' + path: / + servicePort: 3080 + - + kind: Database + name: db + dockerCompose: + environment: + POSTGRES_DB: bunny_books + POSTGRES_PASSWORD: need-to-replace + POSTGRES_USER: postgres + image: postgres + restart: always + user: postgres + ports: + - '5432:5432' + volumes: + - + name: db-data + mount: /var/lib/postgresql/data + subPath: '' +volumes: + - + name: db-data + size: 1Gi + type: disk + - + name: code-server-data + size: 1Gi + type: disk \ No newline at end of file diff --git a/.bunnyshell/templates/showcase-code-server/template.yaml b/.bunnyshell/templates/showcase-code-server/template.yaml index d94e2dbb..3fec7ff7 100644 --- a/.bunnyshell/templates/showcase-code-server/template.yaml +++ b/.bunnyshell/templates/showcase-code-server/template.yaml @@ -6,38 +6,18 @@ tags: - sidecar icons: [ 'vscode', 'docker' ] categories: - - web ides + - web-ides stack: packages: - name: Linuxserver CodeServer - version: '4.90.3' + version: '4.100.2' variables: - - description: 'The hostname for the Code Server service' - name: 'CODE_SERVER_HOST' - type: 'string' - - description: 'Hashed password for authentication' - name: 'HASHED_PASSWORD' - type: 'string' - description: 'Plain text password for authentication' name: 'PASSWORD' type: 'string' - - description: 'Group ID for the container' - name: 'PGID' - type: 'int' - - description: 'Proxy domain for the application' - name: 'PROXY_DOMAIN' - type: 'string' - - description: 'User ID for the container' - name: 'PUID' - type: 'int' - description: 'Sudo password for the container' name: 'SUDO_PASSWORD' type: 'string' - - description: 'Hashed sudo password for the container' - name: 'SUDO_PASSWORD_HASH' - type: 'string' - - description: 'Timezone for the container' - name: 'TZ' - type: 'string' + discoverable: true diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000..c5924b11 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,76 @@ +# Automated Version Update Workflows + +This directory contains GitHub Actions that automatically keep your Bunnyshell templates up-to-date with the latest versions of dependencies. + +## πŸ”„ Code-Server Version Updates + +### Workflows Available + +1. **Daily Update** (`update-code-server-version.yml`) + - **Schedule**: Runs daily at 2 AM UTC + - **Purpose**: Regular version checks and updates + - **Trigger**: Also runs on workflow file changes and manual dispatch + +2. **Frequent Update** (`update-code-server-version-frequent.yml`) + - **Schedule**: Runs every 6 hours + - **Purpose**: More frequent version checks for critical updates + - **Trigger**: Manual dispatch available + +### How It Works + +1. **Version Detection**: Fetches the latest version from Docker Hub registry +2. **Comparison**: Compares current version in `template.yaml` with latest available +3. **Update**: If a newer version exists, updates the file and creates a PR +4. **Automation**: Uses semantic versioning to ensure only valid versions are applied + +### Features + +- βœ… **Smart Updates**: Only creates PRs when updates are actually needed +- βœ… **Pull Request Creation**: Creates descriptive PRs for review +- βœ… **Automatic Branching**: Uses dedicated branches for updates +- βœ… **Labeling**: Applies appropriate labels for easy identification +- βœ… **Manual Triggering**: Can be run manually via GitHub Actions tab +- βœ… **Error Handling**: Gracefully handles API failures and version parsing + +### Configuration + +The workflows automatically: +- Update the `version` field in your `template.yaml` +- Create pull requests with descriptive titles and bodies +- Apply appropriate labels (`automated`, `dependencies`, `code-server`) +- Assign the repository owner for review + +### Manual Usage + +To manually trigger an update: + +1. Go to **Actions** tab in your repository +2. Select **Update Code-Server Version** or **Update Code-Server Version (Frequent)** +3. Click **Run workflow** +4. The action will check for updates and create a PR if needed + +### Customization + +You can modify the workflows to: +- Change update frequency (modify cron schedules) +- Add additional dependencies to track +- Customize PR templates and labels +- Integrate with other CI/CD tools + +### Security + +- Uses `GITHUB_TOKEN` for authentication +- Only updates version strings (no code execution) +- Creates pull requests for review before merging +- Runs in isolated GitHub Actions environment + +### Monitoring + +Monitor the workflows via: +- **Actions** tab for execution history +- **Pull Requests** for pending updates +- **Repository Insights** for automation metrics + +--- + +*These workflows help keep your templates current with the latest security patches and features.* diff --git a/.github/workflows/update-code-server-version-frequent.yml b/.github/workflows/update-code-server-version-frequent.yml new file mode 100644 index 00000000..0e0d2aef --- /dev/null +++ b/.github/workflows/update-code-server-version-frequent.yml @@ -0,0 +1,124 @@ +name: Update Code-Server Version (Frequent) + +on: + schedule: + # Run every 6 hours + - cron: '0 */6 * * *' + workflow_dispatch: # Allow manual triggering + +permissions: + contents: write + pull-requests: write + issues: write + +jobs: + update-version: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Install jq + run: | + sudo apt-get update + sudo apt-get install -y jq + + - name: Get latest Code-Server version + id: get-version + run: | + # Get the latest version from Docker Hub with better error handling + echo "Fetching latest Code-Server version from Docker Hub..." + + # Try to get the latest version + RESPONSE=$(curl -s -w "%{http_code}" "https://registry.hub.docker.com/v2/repositories/linuxserver/code-server/tags/") + HTTP_CODE="${RESPONSE: -3}" + BODY="${RESPONSE%???}" + + if [ "$HTTP_CODE" != "200" ]; then + echo "Error: Failed to fetch from Docker Hub (HTTP $HTTP_CODE)" + exit 1 + fi + + # Extract version using jq + LATEST_VERSION=$(echo "$BODY" | jq -r '.results[] | select(.name | test("^[0-9]+\\.[0-9]+\\.[0-9]+$")) | .name' | sort -V | tail -n 1) + + if [ -z "$LATEST_VERSION" ] || [ "$LATEST_VERSION" = "null" ]; then + echo "Error: Could not extract version from Docker Hub response" + echo "Response body: $BODY" + exit 1 + fi + + echo "Latest Code-Server version: $LATEST_VERSION" + echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT + + - name: Check if version needs updating + id: check-version + run: | + CURRENT_VERSION=$(grep -A 1 "Linuxserver CodeServer" .bunnyshell/templates/showcase-code-server/template.yaml | grep "version:" | sed 's/.*version: //' | tr -d "'") + LATEST_VERSION="${{ steps.get-version.outputs.version }}" + + echo "Current version: $CURRENT_VERSION" + echo "Latest version: $LATEST_VERSION" + + if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then + echo "No update needed" + echo "update_needed=false" >> $GITHUB_OUTPUT + else + echo "Update needed" + echo "update_needed=true" >> $GITHUB_OUTPUT + fi + + - name: Update template.yaml + if: steps.check-version.outputs.update_needed == 'true' + run: | + # Update the version in template.yaml + # Update the version line, preserving indentation + sed -i -E "s/^([[:space:]]*)version: '[0-9]+\.[0-9]+\.[0-9]+'/\1version: '${{ steps.get-version.outputs.version }}'/" .bunnyshell/templates/showcase-code-server/template.yaml + + # Verify the change + echo "Updated template.yaml:" + grep -A 1 "Linuxserver CodeServer" .bunnyshell/templates/showcase-code-server/template.yaml + + - name: Create Pull Request + if: steps.check-version.outputs.update_needed == 'true' + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "chore: update Code-Server to version ${{ steps.get-version.outputs.version }}" + title: "πŸ”„ Update Code-Server to version ${{ steps.get-version.outputs.version }}" + body: | + ## πŸ”„ Code-Server Version Update (Frequent) + + This PR automatically updates the Code-Server version in the template. + + **Changes:** + - Updated Code-Server to latest version **${{ steps.get-version.outputs.version }}** + + **Why this update:** + - Keeps the template up-to-date with the latest Code-Server features + - Ensures security patches are included + - Maintains compatibility with latest Docker images + + **Automated by:** GitHub Action `update-code-server-version-frequent.yml` + + --- + *This PR was automatically generated. Please review and merge if everything looks good.* + branch: update/code-server-version-frequent-${{ steps.get-version.outputs.version }} + delete-branch: true + labels: | + automated + dependencies + code-server + frequent-update + assignees: ${{ github.repository_owner }} + committer: GitHub + author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + + - name: Comment on PR if no update needed + if: steps.check-version.outputs.update_needed == 'false' && github.event_name == 'workflow_dispatch' + run: | + echo "βœ… No update needed. Current version is already up-to-date." diff --git a/.github/workflows/update-code-server-version.yml b/.github/workflows/update-code-server-version.yml new file mode 100644 index 00000000..071a8eef --- /dev/null +++ b/.github/workflows/update-code-server-version.yml @@ -0,0 +1,127 @@ +name: Update Code-Server Version + +on: + schedule: + # Run daily at 2 AM UTC + - cron: '0 2 * * *' + workflow_dispatch: # Allow manual triggering + push: + branches: + - main + paths: + - '.github/workflows/update-code-server-version.yml' + +permissions: + contents: write + pull-requests: write + issues: write + +jobs: + update-version: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Install jq + run: | + sudo apt-get update + sudo apt-get install -y jq + + - name: Get latest Code-Server version + id: get-version + run: | + # Get the latest version from Docker Hub with better error handling + echo "Fetching latest Code-Server version from Docker Hub..." + + # Try to get the latest version + RESPONSE=$(curl -s -w "%{http_code}" "https://registry.hub.docker.com/v2/repositories/linuxserver/code-server/tags/") + HTTP_CODE="${RESPONSE: -3}" + BODY="${RESPONSE%???}" + + if [ "$HTTP_CODE" != "200" ]; then + echo "Error: Failed to fetch from Docker Hub (HTTP $HTTP_CODE)" + exit 1 + fi + + # Extract version using jq + LATEST_VERSION=$(echo "$BODY" | jq -r '.results[] | select(.name | test("^[0-9]+\\.[0-9]+\\.[0-9]+$")) | .name' | sort -V | tail -n 1) + + if [ -z "$LATEST_VERSION" ] || [ "$LATEST_VERSION" = "null" ]; then + echo "Error: Could not extract version from Docker Hub response" + echo "Response body: $BODY" + exit 1 + fi + + echo "Latest Code-Server version: $LATEST_VERSION" + echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT + + - name: Check if version needs updating + id: check-version + run: | + CURRENT_VERSION=$(grep -A 1 "Linuxserver CodeServer" .bunnyshell/templates/showcase-code-server/template.yaml | grep "version:" | sed 's/.*version: //' | tr -d "'") + LATEST_VERSION="${{ steps.get-version.outputs.version }}" + + echo "Current version: $CURRENT_VERSION" + echo "Latest version: $LATEST_VERSION" + + if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then + echo "No update needed" + echo "update_needed=false" >> $GITHUB_OUTPUT + else + echo "Update needed" + echo "update_needed=true" >> $GITHUB_OUTPUT + fi + + - name: Update template.yaml + if: steps.check-version.outputs.update_needed == 'true' + run: | + # Update the version in template.yaml + sed -i "s/version: '[0-9]\+\.[0-9]\+\.[0-9]\+'/version: '${{ steps.get-version.outputs.version }}'/g" .bunnyshell/templates/showcase-code-server/template.yaml + + # Verify the change + echo "Updated template.yaml:" + grep -A 1 "Linuxserver CodeServer" .bunnyshell/templates/showcase-code-server/template.yaml + + - name: Create Pull Request + if: steps.check-version.outputs.update_needed == 'true' + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "chore: update Code-Server to version ${{ steps.get-version.outputs.version }}" + title: "πŸ”„ Update Code-Server to version ${{ steps.get-version.outputs.version }}" + body: | + ## πŸ”„ Code-Server Version Update + + This PR automatically updates the Code-Server version in the template. + + **Changes:** + - Updated Code-Server to latest version **${{ steps.get-version.outputs.version }}** + + **Why this update:** + - Keeps the template up-to-date with the latest Code-Server features + - Ensures security patches are included + - Maintains compatibility with latest Docker images + + **Automated by:** GitHub Action `update-code-server-version.yml` + + --- + *This PR was automatically generated. Please review and merge if everything looks good.* + branch: update/code-server-version-${{ steps.get-version.outputs.version }} + delete-branch: true + labels: | + automated + dependencies + code-server + assignees: ${{ github.repository_owner }} + committer: GitHub + author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + + - name: Comment on PR if no update needed + if: steps.check-version.outputs.update_needed == 'false' && github.event_name == 'workflow_dispatch' + run: | + echo "βœ… No update needed. Current version is already up-to-date."