Dev containers #2
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 and Push CloudHarness Dev Container | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| paths: | |
| - 'Dockerfile' | |
| - 'docker-compose.yml' | |
| - '.devcontainer/**' | |
| - 'dev-scripts/**' | |
| - 'libraries/**' | |
| - 'tools/**' | |
| - 'infrastructure/common-images/**' | |
| pull_request: | |
| branches: | |
| - main | |
| - develop | |
| paths: | |
| - 'Dockerfile' | |
| - 'docker-compose.yml' | |
| - '.devcontainer/**' | |
| - 'dev-scripts/**' | |
| - 'libraries/**' | |
| - 'tools/**' | |
| - 'infrastructure/common-images/**' | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: gcr.io | |
| PROJECT_ID: metacellllc | |
| IMAGE_NAME: cloud-harness/dev-container | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| - name: Configure Docker to use gcloud as a credential helper | |
| run: | | |
| gcloud auth configure-docker | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=sha,prefix={{branch}}- | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./.devcontainer/Dockerfile | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| platforms: linux/amd64,linux/arm64 | |
| - name: Output image details | |
| run: | | |
| echo "Image pushed to: ${{ steps.meta.outputs.tags }}" | |
| echo "Image digest: ${{ steps.build.outputs.digest }}" |