Refactor BigQuery connector and update environment variables (#5) #40
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: Deploy Prefect Flows | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev* | |
| - feature/* | |
| paths-ignore: | |
| - "dbt/**" | |
| - "profiles.yml" | |
| pull_request: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - "dbt/**" | |
| - "profiles.yml" | |
| workflow_dispatch: | |
| env: | |
| GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} | |
| GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
| GCS_TEMP_BUCKET: ${{ secrets.GCS_TEMP_BUCKET }} | |
| GAR_LOCATION: ${{ secrets.GAR_LOCATION || 'us-central1' }} | |
| GAR_REPOSITORY: ${{ secrets.GAR_REPOSITORY || 'prefect-images' }} | |
| IMAGE_NAME: ${{ secrets.GAR_REPOSITORY || 'parsons-prefect-pipeline' }} | |
| GITHUB_SHA: ${{ github.sha }} | |
| ENVIRONMENT: ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }} | |
| jobs: | |
| deploy: | |
| name: Deploy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set environment variables | |
| run: | | |
| echo "TAG=$ENVIRONMENT-$GITHUB_SHA" >> $GITHUB_ENV | |
| echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
| echo "FULL_IMAGE_NAME=$GAR_LOCATION-docker.pkg.dev/$GCP_PROJECT_ID/$GAR_REPOSITORY/$IMAGE_NAME-$ENVIRONMENT:$ENVIRONMENT-$GITHUB_SHA" >> $GITHUB_ENV | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} | |
| - name: Set up Google Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v2 | |
| - name: Debug environment variables | |
| run: | | |
| echo "Branch: ${{ github.ref }}" | |
| echo "ENVIRONMENT: ${{ env.ENVIRONMENT }}" | |
| echo "Is main branch: ${{ github.ref == 'refs/heads/main' }}" | |
| echo "FULL_IMAGE_NAME: ${{ env.FULL_IMAGE_NAME }}" | |
| - name: Configure Docker | |
| run: gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| target: runtime | |
| cache-from: type=registry,ref=${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/${{ env.IMAGE_NAME }}-${{ env.ENVIRONMENT }}:cache | |
| cache-to: type=registry,ref=${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/${{ env.IMAGE_NAME }}-${{ env.ENVIRONMENT }}:cache,mode=max | |
| tags: | | |
| ${{ env.FULL_IMAGE_NAME }} | |
| ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/${{ env.IMAGE_NAME }}-${{ env.ENVIRONMENT }}:latest | |
| build-args: | | |
| ENVIRONMENT=${{ env.ENVIRONMENT }} | |
| GCP_PROJECT_ID=${{ env.GCP_PROJECT_ID }} | |
| GCS_TEMP_BUCKET=${{ env.GCS_TEMP_BUCKET }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Setup UV | |
| id: setup-uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Install Dependencies | |
| run: | | |
| uv pip install --system . | |
| - name: Prefect Deploy | |
| env: | |
| PREFECT_API_KEY: ${{ secrets.PREFECT_API_KEY }} | |
| PREFECT_API_URL: ${{ secrets.PREFECT_API_URL }} | |
| ENVIRONMENT: ${{ env.ENVIRONMENT }} | |
| BRANCH_NAME: ${{ env.BRANCH_NAME }} | |
| run: | | |
| python pipelines/flows/deploy_flows.py |