update github remote build action to push to different container regi… #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build remote build docker image | |
on: | |
push: | |
branches: | |
- "feature/*" | |
workflow_dispatch: | |
env: | |
REGISTRY: ${{ secrets.REGISTRY }} | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-20.04 | |
if: "${{ !startsWith(github.event.head_commit.message, 'GitBook: [#') }}" | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- id: "auth" | |
name: "Authenticate to Google Cloud" | |
uses: "google-github-actions/auth@v1" | |
with: | |
token_format: "access_token" | |
workload_identity_provider: ${{ secrets.GAR_WORKLOAD_IDENTITY_PROVIDER }} | |
service_account: ${{ secrets.GAR_SERVICE_ACCOUNT }} | |
- name: Login to GCR | |
uses: docker/login-action@v1 | |
with: | |
registry: gcr.io | |
username: oauth2accesstoken | |
password: ${{ steps.auth.outputs.access_token }} | |
- name: Generate docker tags/labels from github build context | |
id: meta | |
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-remotebuild | |
tags: | | |
type=ref,event=tag | |
type=sha,prefix= | |
type=raw,enable=${{ github.ref == 'refs/heads/develop' }},value=develop | |
type=raw,enable=${{ startsWith(github.ref, 'refs/heads/release/v') }},value=${{ steps.extract_branch.outputs.release_train }} | |
flavor: | | |
latest=${{ startsWith(github.ref, 'refs/tags/') }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | |
with: | |
secrets: | | |
"github_token=${{ secrets.GHUB_ACCESS_TOKEN }}" | |
context: . | |
file: ./Dockerfile.remotebuild | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
# org.opencontainers.image.version will match the tag name | |
labels: ${{ steps.meta.outputs.labels }} |