Build Single DevContainer #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Single DevContainer | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| devcontainer_choice: | |
| description: 'DevContainer to build (only those with Dockerfiles)' | |
| required: true | |
| type: choice | |
| options: | |
| - 'default-container' | |
| - 'codex-container' | |
| - 'ai-container' | |
| - 'llm-container' | |
| - 'wassette-container' | |
| default: 'default-container' | |
| image_tag: | |
| description: 'Image tag (e.g., latest, v1.0.0)' | |
| required: false | |
| default: 'latest' | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set image name | |
| id: image-name | |
| run: | | |
| devcontainer="${{ github.event.inputs.devcontainer_choice }}" | |
| # Remove -container suffix if it exists | |
| image_name="${devcontainer%-container}" | |
| echo "name=$image_name" >> $GITHUB_OUTPUT | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ github.repository }}/${{ steps.image-name.outputs.name }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=raw,value=${{ github.event.inputs.image_tag || 'latest' }} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./.devcontainer/${{ github.event.inputs.devcontainer_choice }} | |
| file: ./.devcontainer/${{ github.event.inputs.devcontainer_choice }}/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha,scope=${{ github.event.inputs.devcontainer_choice }} | |
| cache-to: type=gha,mode=max,scope=${{ github.event.inputs.devcontainer_choice }} | |
| - name: Output image details | |
| run: | | |
| echo "Built devcontainer: ${{ github.event.inputs.devcontainer_choice }}" | |
| echo "Tags: ${{ steps.meta.outputs.tags }}" |