|
| 1 | +name: Build Internal Docker Images |
| 2 | +on: |
| 3 | + workflow_dispatch: {} |
| 4 | + schedule: |
| 5 | + # 4:05AM On Thursdays for vuln assessments. |
| 6 | + - cron: '5 4 * * 4' |
| 7 | +jobs: |
| 8 | + build-image: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + permissions: |
| 11 | + contents: 'read' |
| 12 | + id-token: 'write' |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + python: |
| 16 | + # A matrix in the event we want to add more |
| 17 | + # python versions to this list. |
| 18 | + - "3.11" |
| 19 | + env: |
| 20 | + GCP_DOCKER_REPOSITORY: dev-docker |
| 21 | + GCP_LOCATION: us-central1 |
| 22 | + steps: |
| 23 | + - name: Clone fiftyone |
| 24 | + uses: actions/checkout@v4 |
| 25 | + - name: Authenticate to Google Cloud |
| 26 | + uses: google-github-actions/auth@v2 |
| 27 | + with: |
| 28 | + project_id: ${{ secrets.REPO_GCP_PROJECT }} |
| 29 | + service_account: ${{ secrets.REPO_GCP_SERVICE_ACCOUNT }} |
| 30 | + workload_identity_provider: ${{ secrets.REPO_GOOGLE_WORKLOAD_IDP }} |
| 31 | + - name: Set Up Cloud SDK |
| 32 | + uses: google-github-actions/setup-gcloud@v2 |
| 33 | + - name: Docker login |
| 34 | + run: | |
| 35 | + gcloud auth configure-docker "${{ env.GCP_LOCATION }}-docker.pkg.dev" --quiet |
| 36 | + - name: Set Env Vars |
| 37 | + run: | |
| 38 | + fo_version=$(python3 -c 'import re; f=open("./setup.py").read(); print(re.search(r"VERSION\s*=\s*\"([^\"]+)\"", f).group(1))') |
| 39 | + short_sha="$(git rev-parse --short HEAD)" |
| 40 | + echo "fo_version=$fo_version" >> "$GITHUB_ENV" |
| 41 | + echo "pyver=${{ matrix.python }}" >> "$GITHUB_ENV" |
| 42 | + echo "short_sha=$short_sha" >> "$GITHUB_ENV" |
| 43 | + echo "today=$(date +%Y%m%d)" >> "$GITHUB_ENV" |
| 44 | + - name: Set up Docker Buildx |
| 45 | + uses: docker/setup-buildx-action@v3 |
| 46 | + - name: Build and push internal image |
| 47 | + uses: docker/build-push-action@v6 |
| 48 | + with: |
| 49 | + build-args: | |
| 50 | + BUILD_TYPE=released |
| 51 | + FO_VERSION=${{ env.fo_version }} |
| 52 | + PYTHON_VERSION=${{ env.pyver }} |
| 53 | + context: . |
| 54 | + # Not doing multi-platform builds as the intent of this |
| 55 | + # is for security scanning. |
| 56 | + # Multi-platform builds take an additional 10 minutes to build |
| 57 | + # and this seems like it would give us the same level of scanning |
| 58 | + # functionality. |
| 59 | + push: true |
| 60 | + sbom: true |
| 61 | + tags: | |
| 62 | + ${{ env.GCP_LOCATION }}-docker.pkg.dev/${{ secrets.REPO_GCP_PROJECT }}/${{ env.GCP_DOCKER_REPOSITORY }}/fiftyone:${{ env.fo_version }}-${{ env.short_sha }}-python${{ env.pyver }}-${{ env.today }} |
0 commit comments