Use environment variables for S3 bucket prefixes (#395) #80
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 images (dev) | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: Git ref to build | |
| required: false | |
| default: main | |
| version_tag: | |
| description: Optional Docker tag | |
| required: false | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - name: index | |
| dockerfile: Dockerfile.index | |
| - name: ttc | |
| dockerfile: Dockerfile.ttc | |
| - name: augmentation | |
| dockerfile: Dockerfile.augmentation | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.inputs.ref || github.ref }} | |
| - name: Make repo owner lowercase | |
| id: repo | |
| run: | | |
| echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| - name: Detect changes | |
| id: changes | |
| uses: dorny/paths-filter@v4 | |
| with: | |
| filters: | | |
| index: | |
| - 'Dockerfile.index' | |
| - 'packages/index-lambda/**' | |
| - name: Set up Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ghcr.io/${{ steps.repo.outputs.owner }}/dibbs-text-to-code/${{ matrix.name }} | |
| tags: | | |
| type=raw,value=${{ github.event.inputs.version_tag }},enable=${{ github.event.inputs.version_tag != '' }} | |
| type=ref,event=branch | |
| type=raw,value=latest,enable=${{ github.ref_name == 'main' }} | |
| - name: Build and push image | |
| if: ${{ matrix.name != 'index' || github.event_name == 'workflow_dispatch' || steps.changes.outputs.index == 'true' }} | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| file: ${{ matrix.dockerfile }} | |
| push: true | |
| platforms: linux/amd64 | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| secrets: | | |
| "huggingface_token=${{ secrets.HF_TOKEN }}" | |
| - name: Configure APHL AWS credentials | |
| if: ${{ matrix.name != 'index' }} | |
| uses: aws-actions/configure-aws-credentials@v6 | |
| with: | |
| aws-access-key-id: ${{ secrets.APHL_AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.APHL_AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Login to APHL ECR | |
| if: ${{ matrix.name != 'index' }} | |
| id: aphl-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Push to APHL ECR | |
| if: ${{ matrix.name != 'index' }} | |
| run: | | |
| GHCR_IMAGE="ghcr.io/${{ steps.repo.outputs.owner }}/dibbs-text-to-code/${{ matrix.name }}:latest" | |
| ECR_IMAGE="${{ secrets.APHL_ECR_REPOSITORY_URL }}/${{ matrix.name }}:latest" | |
| docker buildx imagetools create --tag "$ECR_IMAGE" "$GHCR_IMAGE" |