Skip to content

Dagster Cleanup

Dagster Cleanup #2854

Workflow file for this run

name: Create Docker Image
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
IMAGE_NAME: cfa-stf-routine-forecasting
jobs:
# This can be used as a template, later: https://github.com/CDCgov/cfa-epinow2-pipeline/blob/main/.github/workflows/containers-and-az-pool.yaml
build-pipeline-image:
runs-on: ubuntu-latest
name: Build image
outputs:
tag: ${{ steps.image-tag.outputs.tag }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: branch-name
- name: Figure out tag (either latest if it is main or the branch name)
shell: bash
id: image-tag
run: |
if [ "${{ steps.branch-name.outputs.branch }}" = "main" ]; then
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "tag=$(echo "${{ steps.branch-name.outputs.branch }}" | tr '/' '-')" >> $GITHUB_OUTPUT
fi
- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Docker build and push
uses: docker/build-push-action@v6
with:
context: .
file: Containerfile
push: true
builder: ${{ steps.buildx.outputs.name }}
tags: |
ghcr.io/cdcgov/${{ env.IMAGE_NAME }}:${{ steps.image-tag.outputs.tag }}
build-args: |
GIT_COMMIT_SHA=${{ github.event.pull_request.head.sha || github.sha }}
GIT_BRANCH_NAME=${{ steps.branch-name.outputs.branch }}
cache-from: |
type=registry,ref=ghcr.io/cdcgov/${{ env.IMAGE_NAME }}:${{ steps.image-tag.outputs.tag }}-cache
type=registry,ref=ghcr.io/cdcgov/${{ env.IMAGE_NAME }}:latest-cache
cache-to: type=registry,ref=ghcr.io/cdcgov/${{ env.IMAGE_NAME }}:${{ steps.image-tag.outputs.tag }}-cache,mode=max
deploy_dagster_code:
needs: build-pipeline-image
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
name: Update Dagster Code Location
permissions:
contents: read
packages: write
steps:
- name: Run update script with cfa runner-action
uses: CDCgov/cfa-actions/runner-action@v1.5.0
with:
github_app_id: ${{ secrets.REPO_CDCENT_ACTOR_APP_ID }}
github_app_pem: ${{ secrets.REPO_CDCENT_ACTOR_APP_PEM }}
script: |
echo "Running update script"
uv run \
https://raw.githubusercontent.com/CDCgov/cfa-dagster/refs/heads/main/scripts/update_code_location.py \
--registry_image ghcr.io/cdcgov/cfa-stf-routine-forecasting:${{ needs.build-pipeline-image.outputs.tag }}