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 1d58aaa commit f25f8ea
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 4 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/build-go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
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:
service:
- 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: 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: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
context: .
file: ./docker/Dockerfile.go-services
build-args: |
BUILD_TARGET=${{matrix.service}}
tags: |
${{env.GCP_REGION}}-docker.pkg.dev/${{env.GCP_PROJECT_ID}}/basemind/${{matrix.service}}:latest
${{env.GCP_REGION}}-docker.pkg.dev/${{env.GCP_PROJECT_ID}}/basemind/${{matrix.service}}:${{github.sha}}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ jobs:
run: curl -sSf https://atlasgo.sh | sh
- name: Authenticate with GCP
id: auth
uses: google-github-actions/auth@v1.1.1
uses: google-github-actions/auth@v1
with:
workload_identity_provider: 'projects/${GCP_PROJECT_NUMBER}/locations/global/workloadIdentityPools/${GCP_WORKLOAD_IDENTITY_POOL}/providers/${GCP_OIDC_PROVIDER_NAME}'
service_account: '${GCP_SERVICE_ACCOUNT_NAME}@${GCP_PROJECT_ID}.iam.gserviceaccount.com'
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 f25f8ea

Please sign in to comment.