Skip to content
Snippets Groups Projects
Commit 6b8c791c authored by Austin Anderson's avatar Austin Anderson
Browse files

Combine Docker GCR presubmits and also push main to gcr

parent 883b3b8d
No related branches found
No related tags found
No related merge requests found
name: Upload requested containers to gcr.io
on:
pull_request:
types: [labeled]
paths:
- '.github/workflows/docker-gcr.yml'
- 'tf_sig_build_dockerfiles/**'
- '!tf_sig_build_dockerfiles/README.md'
jobs:
docker:
if: ${{ github.event.label.name == 'build and push to gcr.io for staging' }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [python3.7, python3.8, python3.9]
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Clear the build-and-push label
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: build and push to gcr.io for staging
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to GCR
uses: docker/login-action@v1
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCP_CREDS }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
context: ./tf_sig_build_dockerfiles
target: devel
build-args: |
PYTHON_VERSION=${{ matrix.python-version }}
tags: |
gcr.io/tensorflow-sigs/build:${{ github.event.number }}-${{ matrix.python-version }}
cache-from: |
type=registry,ref=tensorflow/build:latest-${{ matrix.python-version }}
type=registry,ref=gcr.io/tensorflow-sigs/build:${{ github.event.number }}-${{ matrix.python-version }}
cache-to: type=inline
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
-
name: Add a comment with the pushed containers
uses: mshick/add-pr-comment@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
message: |
I pushed these containers:
- `gcr.io/tensorflow-sigs/build:${{ github.event.number }}-python3.9`
- `gcr.io/tensorflow-sigs/build:${{ github.event.number }}-python3.8`
- `gcr.io/tensorflow-sigs/build:${{ github.event.number }}-python3.7`
Re-apply the `build and push to gcr.io for staging` label to
rebuild and push again. This comment will only be posted once.
# Run on pull requests. name: Upload requested containers to gcr.io
# Builds Docker images but doesn't push them anywhere.
name: Docker presubmit
on: on:
# Allow manual testing on side braches
workflow_dispatch:
pull_request: pull_request:
types: [labeled]
paths: paths:
- '.github/workflows/docker-gcr.yml'
- 'tf_sig_build_dockerfiles/**' - 'tf_sig_build_dockerfiles/**'
- '!tf_sig_build_dockerfiles/README.md' - '!tf_sig_build_dockerfiles/README.md'
branches:
- master
jobs: jobs:
docker: docker:
if: ${{ github.event.label.name == 'build and push to gcr.io for staging' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
python-version: [python3.7, python3.8, python3.9] python-version: [python3.7, python3.8, python3.9]
steps: steps:
- -
name: Checkout this repository name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
-
name: Clear the build-and-push label
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: build and push to gcr.io for staging
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
...@@ -29,16 +31,42 @@ jobs: ...@@ -29,16 +31,42 @@ jobs:
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- -
name: Build containers name: Login to GCR
uses: docker/login-action@v1
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCP_CREDS }}
-
name: Build and push
id: docker_build id: docker_build
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
push: false push: true
context: ./tf_sig_build_dockerfiles context: ./tf_sig_build_dockerfiles
target: devel target: devel
build-args: | build-args: |
PYTHON_VERSION=${{ matrix.python-version }} PYTHON_VERSION=${{ matrix.python-version }}
tags: tensorflow/build:latest-${{ matrix.python-version }} tags: |
cache-from: type=registry,ref=tensorflow/build:latest-${{ matrix.python-version }} gcr.io/tensorflow-sigs/build:${{ github.event.number }}-${{ matrix.python-version }}
cache-from: |
type=registry,ref=tensorflow/build:latest-${{ matrix.python-version }}
type=registry,ref=gcr.io/tensorflow-sigs/build:${{ github.event.number }}-${{ matrix.python-version }}
cache-to: type=inline cache-to: type=inline
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
-
name: Add a comment with the pushed containers
uses: mshick/add-pr-comment@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
message: |
I pushed these containers:
- `gcr.io/tensorflow-sigs/build:${{ github.event.number }}-python3.9`
- `gcr.io/tensorflow-sigs/build:${{ github.event.number }}-python3.8`
- `gcr.io/tensorflow-sigs/build:${{ github.event.number }}-python3.7`
Re-apply the `build and push to gcr.io for staging` label to
rebuild and push again. This comment will only be posted once.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment