Added Debug info #5
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 Dagster Docker Image | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| image_tag: | |
| description: 'Docker image tag (e.g., v1.0.0)' | |
| required: true | |
| default: 'latest' | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '**/*.py' # Any Python file changes | |
| - '**/*.toml' # Any TOML file changes | |
| - 'Dockerfile' # Dockerfile changes | |
| - '.github/workflows/*.yml' # Workflow file changes | |
| - 'requirements.txt' # If you have requirements.txt | |
| - 'README.md' # README changes | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the code | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| # Step 2: Set up Docker Buildx | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| # Step 3: Log in to Docker Hub | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| # Enhanced debug information | |
| - name: Debug Info | |
| run: | | |
| echo "==== Build Context ====" | |
| echo "Event name: ${{ github.event_name }}" | |
| echo "Branch name: ${{ github.ref }}" | |
| echo "Commit SHA: ${{ github.sha }}" | |
| echo "Workflow: ${{ github.workflow }}" | |
| echo "==== Repository Info ====" | |
| echo "Repository: ${{ github.repository }}" | |
| echo "Default branch: ${{ github.event.repository.default_branch }}" | |
| echo "==== Commit Info ====" | |
| echo "Commit message: ${{ github.event.head_commit.message }}" | |
| echo "Committed by: ${{ github.event.head_commit.author.name }}" | |
| echo "==== Changed Files ====" | |
| if git rev-parse --verify HEAD^1 >/dev/null 2>&1; then | |
| git diff --name-only HEAD^1 HEAD | |
| else | |
| echo "First commit or shallow clone - listing all files:" | |
| git ls-files | |
| fi | |
| echo "==== Environment ====" | |
| echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE" | |
| echo "Current directory: $(pwd)" | |
| ls -la | |
| - name: Set image tag | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "IMAGE_TAG=${{ github.event.inputs.image_tag }}" >> $GITHUB_ENV | |
| else | |
| echo "IMAGE_TAG=latest" >> $GITHUB_ENV | |
| fi | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/dagster-usercode:${{ env.IMAGE_TAG }} | |
| ${{ secrets.DOCKERHUB_USERNAME }}/dagster-usercode:latest | |
| # Step 7: Update Kubernetes deployment (if needed) | |
| - name: Update Kubernetes deployment | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| echo "New image has been pushed: ${{ secrets.DOCKERHUB_USERNAME }}/dagster-usercode:${{ env.IMAGE_TAG }}" | |
| echo "To update your Dagster deployment, run:" | |
| echo "kubectl patch userdeployment my-dagster-project --type=json -p='[{\"op\": \"replace\", \"path\": \"/spec/deployment/image/tag\", \"value\": \"${{ env.IMAGE_TAG }}\"}]'" | |
| # Step 8: Image digest | |
| - name: Image digest | |
| run: echo ${{ steps.build.outputs.digest }} |