Skip to content

Commit

Permalink
extract reusable
Browse files Browse the repository at this point in the history
  • Loading branch information
typotter committed Nov 18, 2024
1 parent a326898 commit 0b323c8
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 80 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build and push SDK Test Runner

on:
workflow_dispatch:
inputs:
version:
description: 'Version string for SDK Test Runner release'
required: true
default: '1.0.0'
docker_context:
description: 'Directory where dockerfile exists'
required: true
image_name:
description: 'Docker image name'
required: true

env:
VERSION: 1.1.0

PROJECT_ID: ${{ vars.SDK_TESTING_PROJECT_ID }}
REGION: ${{ vars.SDK_TESTING_REGION }}
GAR_LOCATION: ${{ vars.SDK_TESTING_REGION }}-docker.pkg.dev/${{ vars.SDK_TESTING_PROJECT_ID }}/sdk-testing


jobs:
build-and-upload:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3

# Set up gCloud
- id: "auth"
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"

- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"

- name: "Use gcloud CLI"
run: "gcloud info"

# Allow docker access to the GAR
- name: "Docker auth"
run: |-
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
# Build and push
- name: Build and export
uses: docker/build-push-action@v6
with:
push: true
context: ${{ inputs.docker_context }}
tags: ${{ env.GAR_LOCATION }}/${{ inputs.image_name }}:latest,${{ env.GAR_LOCATION }}/${{ inputs.image_name }}:${{ env.VERSION }}
46 changes: 6 additions & 40 deletions .github/workflows/release-sdk-test-runner.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,23 @@
name: Build and Push to Artifact Registry
name: Build and push SDK Test Runner

on:
workflow_dispatch:
inputs:
version:
description: 'Version string for SDK Test Runner release'
required: true
default: '1'
default: '1.0.0'

push:
paths:
.github/workflows/*

env:
VERSION: 1.1.0

PROJECT_ID: ${{ vars.SDK_TESTING_PROJECT_ID }}
REGION: ${{ vars.SDK_TESTING_REGION }}
GAR_LOCATION: ${{ vars.SDK_TESTING_REGION }}-docker.pkg.dev/${{ vars.SDK_TESTING_PROJECT_ID }}/sdk-testing


jobs:
build-and-upload:
runs-on: ubuntu-latest
defaults:
run:
working-directory: "package-testing/sdk-test-runner"

steps:
- name: "Checkout"
uses: actions/checkout@v3

# Set up gCloud
- id: "auth"
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"

- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"

- name: "Use gcloud CLI"
run: "gcloud info"

# Allow docker access to the GAR
- name: "Docker auth"
run: |-
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
# Build and push
- name: Build and export
uses: docker/build-push-action@v6
- uses: ./.github/workflows/build-and-push.yml
with:
push: true
context: ./package-testing/sdk-test-runner
tags: ${{ env.GAR_LOCATION }}/sdk-test-runner:latest,${{ env.GAR_LOCATION }}/sdk-test-runner:${{ env.VERSION }}
version: ${{ inputs.version }}
docker_contex: ./package-testing/sdk-test-runner
image_name: sdk-test-runner
46 changes: 6 additions & 40 deletions .github/workflows/release-sdk-testing-api.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,23 @@
name: Build and Push to Artifact Registry
name: Build and push Testing API

on:
workflow_dispatch:
inputs:
version:
description: 'Version string for SDK Testing API release'
required: true
default: '1'
default: '1.0.0'

push:
paths:
.github/workflows/*

env:
VERSION: 1.1.0

PROJECT_ID: ${{ vars.SDK_TESTING_PROJECT_ID }}
REGION: ${{ vars.SDK_TESTING_REGION }}
GAR_LOCATION: ${{ vars.SDK_TESTING_REGION }}-docker.pkg.dev/${{ vars.SDK_TESTING_PROJECT_ID }}/sdk-testing


jobs:
build-and-upload:
runs-on: ubuntu-latest
defaults:
run:
working-directory: "package-testing/testing-api"

steps:
- name: "Checkout"
uses: actions/checkout@v3

# Set up gCloud
- id: "auth"
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"

- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"

- name: "Use gcloud CLI"
run: "gcloud info"

# Allow docker access to the GAR
- name: "Docker auth"
run: |-
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
# Build and push
- name: Build and export
uses: docker/build-push-action@v6
- uses: ./.github/workflows/build-and-push.yml
with:
push: true
context: ./package-testing/testing-api
tags: ${{ env.GAR_LOCATION }}/testing-api:latest,${{ env.GAR_LOCATION }}/testing-api:${{ env.VERSION }}
version: 1.0.0
docker_contex: ./package-testing/testing-api
image_name: testing-api

0 comments on commit 0b323c8

Please sign in to comment.