Skip to content

Commit

Permalink
feat: add docker build and push actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldziher committed Oct 14, 2023
1 parent 1df09a8 commit 2161fc4
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 57 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/build-go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: 'Build'
on:
push:
branches:
- main
pull_request:
branches:
- main
# workflow_run:
# branches:
# - main
# workflows:
# - "Tests (Golang)"
# types:
# - completed
env:
GCP_OIDC_PROVIDER_NAME: github-provider
GCP_PROJECT_ID: basemind-ai-development
GCP_PROJECT_NUMBER: 78794879644
GCP_SERVICE_ACCOUNT_NAME: github-actions
GCP_WORKLOAD_IDENTITY_POOL: dev-pool
GCP_REGION: europe-west3
jobs:
build:
#if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') # run only on tagged commits
runs-on: ubuntu-latest
# strategy:
# matrix:
# services:
# - api-gateway
# - dashboard-backend
permissions:
contents: 'read'
id-token: 'write'
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v1
with:
token_format: access_token
workload_identity_provider: projects/${{env.GCP_PROJECT_NUMBER}}/locations/global/workloadIdentityPools/${{env.GCP_WORKLOAD_IDENTITY_POOL}}/providers/${{env.GCP_OIDC_PROVIDER_NAME}}
service_account: ${{env.GCP_SERVICE_ACCOUNT_NAME}}@${{env.GCP_PROJECT_ID}}.iam.gserviceaccount.com
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
- name: Login to Artifact Registry
uses: docker/login-action@v3
with:
registry: ${{env.GCP_REGION}}-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Create image tag
id: get-tag
run: echo ::set-output name=short_ref::${GITHUB_REF#refs/*/}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
context: .
file: ./docker/Dockerfile.go-services
build-args: |
BUILD_TARGET=dashboard-backend
tags: |
${{env.GCP_REGION}}-docker.pkg.dev/${{env.GCP_PROJECT_ID}}/monorepo/dashboard-backend:${{ steps.get-tag.outputs.short_ref }}
${{env.GCP_REGION}}-docker.pkg.dev/${{env.GCP_PROJECT_ID}}/monorepo/dashboard-backend:latest
56 changes: 0 additions & 56 deletions .github/workflows/ci-tests-go.yaml

This file was deleted.

File renamed without changes.
56 changes: 56 additions & 0 deletions .github/workflows/tests-go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#name: 'Tests (Golang)'
#on:
# push:
# branches:
# - main
# pull_request:
# branches:
# - main
# paths:
# - 'gen/go/**'
# - 'go.*'
# - 'services/api-gateway/**'
# - 'services/dashboard-backend/**'
# - 'shared/go/**'
#env:
# GCP_OIDC_PROVIDER_NAME: github-provider
# GCP_PROJECT_ID: basemind-ai-development
# GCP_PROJECT_NUMBER: 78794879644
# GCP_SERVICE_ACCOUNT_NAME: firebase-adminsdk-frgvx
# GCP_WORKLOAD_IDENTITY_POOL: dev-pool
# TEST_SLEEP_TIMEOUT: 1s
#jobs:
# test:
# runs-on: ubuntu-latest
# permissions:
# contents: read
# id-token: write
# steps:
# - uses: actions/checkout@v4
# - name: Setup Golang
# uses: actions/setup-go@v4
# with:
# go-version: '1.21'
# - name: Load cached Golang dependencies
# id: cached-go-dependencies
# uses: actions/cache@v3
# with:
# path: |
# ~/.cache/go-build
# ~/go/pkg/mod
# key: go-${{ inputs.go_version }}-v1.0-${{ hashFiles('**/go.sum') }}
# - name: Install Golang dependencies
# if: steps.cached-go-dependencies.outputs.cache-hit != 'true'
# shell: bash
# run: go get -v -t ./...
# - name: Install Atlas
# shell: bash
# run: curl -sSf https://atlasgo.sh | sh
# - name: Authenticate with GCP
# id: auth
# uses: google-github-actions/auth@v1
# with:
# workload_identity_provider: projects/${{env.GCP_PROJECT_NUMBER}}/locations/global/workloadIdentityPools/${{env.GCP_WORKLOAD_IDENTITY_POOL}}/providers/${{env.GCP_OIDC_PROVIDER_NAME}}
# service_account: ${{env.GCP_SERVICE_ACCOUNT_NAME}}@${{env.GCP_PROJECT_ID}}.iam.gserviceaccount.com
# - name: Test
# run: go test ./...
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Golang
uses: actions/setup-go@v4
with:
Expand Down

0 comments on commit 2161fc4

Please sign in to comment.