Namespace built containers by github-org/repo/branch

So that zebra and zebra2-* repos can all be in the same GCloud project without
clobbering each other in the Container Registry namespace
This commit is contained in:
Deirdre Connolly 2019-09-05 13:06:45 -04:00 committed by Deirdre Connolly
parent c27f97c652
commit dceefc164b
4 changed files with 26 additions and 51 deletions

24
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,24 @@
name: CI
on: [push]
jobs:
build:
name: Google Cloud Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- run:
- name: Authenticate w/ Google Cloud
uses: actions/gcloud/auth@master
env:
GCLOUD_AUTH: ${{ secrets.GCLOUD_AUTH }}
- name: Build, Test, Push to GCR
uses: actions/gcloud/cli@master
with:
entrypoint: bash
args: |
-l -c "BRANCH_NAME=$GITHUB_REPOSITORY/$(expr $GITHUB_REF : '.*/\(.*\)') && \
BRANCH_NAME=${BRANCH_NAME,,} && \
gcloud builds submit . --config cloudbuild.yaml --project zealous-zebra --substitutions BRANCH_NAME=$BRANCH_NAME"

View File

@ -1,31 +0,0 @@
name: On Push
on: push
jobs:
build:
name: Google Cloud Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Authenticate w/ Google Cloud
uses: actions/gcloud/auth@master
env:
GCLOUD_AUTH: ${{ secrets.GCLOUD_AUTH }}
- name: Build, Test, Push to GCR
uses: actions/gcloud/cli@master
with:
entrypoint: sh
args: -l -c "SHORT_SHA=$(echo ${{ github.sha }} | head -c7) && BRANCH_NAME=$(git
name-rev --name-only HEAD) && gcloud builds submit . --config cloudbuild.yaml
--project zealous-zebra --substitutions BRANCH_NAME=$BRANCH_NAME"
# If this is uncommented, it will pull the image it `uses` even if the
# conditional expression evaluates to 'false'.
#
# - name: Build Fuzzers
# if: startsWith(github.ref, 'ref/heads/master') && endsWith(github.ref, 'ref/heads/master')
# uses: docker://gcr.io/zebrad/master:latest
# with:
# entrypoint: sh
# args: -c "cd fuzz/; cargo install --force afl honggfuzz; cargo hfuzz build; cargo afl build; exit 0"

View File

@ -10,12 +10,6 @@ WORKDIR /zebra
ENV RUST_BACKTRACE 1
ENV CARGO_HOME /zebra/.cargo/
# Copy cached target/ from master
# COPY --from=gcr.io/zebrad/master:latest /zebra/target /zebra/target
# Copy cached .cargo/ from master
# COPY --from=gcr.io/zebrad/master:latest /zebra/.cargo /zebra/.cargo
# Copy local code to the container image.
# Assumes that we are in the git repo.

View File

@ -1,21 +1,9 @@
steps:
# - name: 'gcr.io/cloud-builders/docker'
# entrypoint: 'bash'
# args:
# - '-c'
# - |
# docker pull gcr.io/$PROJECT_ID/master:latest || exit 0
# - name: 'gcr.io/cloud-builders/docker'
# entrypoint: 'bash'
# args:
# - '-c'
# - |
# docker run gcr.io/kaniko-project/warmer:latest --image=gcr.io/$PROJECT_ID/$BRANCH_NAME:latest --image=gcr.io/$PROJECT_ID/master:latest || exit 0
- name: 'gcr.io/kaniko-project/executor:latest'
args:
- --destination=gcr.io/$PROJECT_ID/$BRANCH_NAME #:$SHORT_SHA
- --destination=gcr.io/$PROJECT_ID/$BRANCH_NAME
- --cache=true
- --cache-ttl=12h
- --cache-ttl=24h
options:
machineType: 'N1_HIGHCPU_32'