|
| 1 | +# Copyright 2023 Google LLC |
| 2 | + |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | + |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: Build and push Docker image to GCP Artifact Registry with the latest Beam |
| 16 | + |
| 17 | +on: |
| 18 | + workflow_dispatch: |
| 19 | + |
| 20 | +jobs: |
| 21 | + build-and-push: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Free Disk Space (Ubuntu) |
| 26 | + uses: jlumbroso/free-disk-space@main |
| 27 | + with: |
| 28 | + # this might remove tools that are actually needed, |
| 29 | + # if set to "true" but frees about 6 GB |
| 30 | + tool-cache: false |
| 31 | + |
| 32 | + android: true |
| 33 | + dotnet: true |
| 34 | + haskell: true |
| 35 | + large-packages: false |
| 36 | + docker-images: true |
| 37 | + swap-storage: true |
| 38 | + - name: Checkout |
| 39 | + uses: actions/checkout@v3 |
| 40 | + - id: "auth" |
| 41 | + name: Authenticate to Google Cloud |
| 42 | + uses: google-github-actions/[email protected] |
| 43 | + with: |
| 44 | + credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }} |
| 45 | + token_format: access_token |
| 46 | + - name: Docker login |
| 47 | + uses: "docker/login-action@v1" |
| 48 | + with: |
| 49 | + registry: "us-docker.pkg.dev" |
| 50 | + username: "oauth2accesstoken" |
| 51 | + password: "${{ steps.auth.outputs.access_token }}" |
| 52 | + - name: Set up Python 3.8 |
| 53 | + uses: actions/setup-python@v4 |
| 54 | + with: |
| 55 | + python-version: "3.8" |
| 56 | + - name: Init env with the test Beam and docker URI |
| 57 | + run: | |
| 58 | + cp tests/sample.env.tf .env |
| 59 | + make init-venv |
| 60 | + ./venv/bin/pip install requests packaging |
| 61 | + make test-latest-env |
| 62 | + sed -i '/CUSTOM_CONTAINER_IMAGE=/d' .env |
| 63 | + echo -e "\n" >> .env |
| 64 | + echo "CUSTOM_CONTAINER_IMAGE=us-docker.pkg.dev/apache-beam-testing/dataflow-ml-starter/tf_gpu:test-beam" >> .env |
| 65 | + echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://us-docker.pkg.dev |
| 66 | + make init |
| 67 | + - name: Build and push Docker image |
| 68 | + run: | |
| 69 | + make docker |
| 70 | + - name: Test Docker image |
| 71 | + run: | |
| 72 | + make run-df-gpu |
0 commit comments