Skip to content

Commit

Permalink
chore: add github action ci for docker image builds (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
aseem-deepsource committed Jul 24, 2023
1 parent 4741e95 commit 4137a0a
Show file tree
Hide file tree
Showing 4 changed files with 1,970 additions and 6 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI
on:
push:
branches:
- master
tags:
- '**'
pull_request:

jobs:
build:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set tag & repo name for PR builds
if: ${{ !contains(fromJson('["refs/heads/master" ]'), github.ref) }}
run: |
echo "IMAGE_TAG=PR-${{ github.event.number }}" >> $GITHUB_ENV
echo "REPO=deepsource-dev" >> $GITHUB_ENV
- name: Set tag & repo name for master builds
if: contains(fromJson('["refs/heads/master"]'), github.ref)
run: |
echo "IMAGE_TAG=master" >> $GITHUB_ENV
echo "REPO=deepsource-dev" >> $GITHUB_ENV
- name: Set tag & repo name for releases
if: startsWith(github.event.ref, 'refs/tags/v')
run: |
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
echo "REPO=deepsource-production" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Authenticate to Google Cloud Development
if: ${{ !startsWith(github.event.ref, 'refs/tags/v') }}
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.DS_GHA_SA_DEV }}"

- name: Authenticate to Google Cloud Production
if: startsWith(github.event.ref, 'refs/tags/v')
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.DS_GHA_SA_PROD }}"

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

- name: Configure docker for gcr
run: |
gcloud auth configure-docker
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: us.gcr.io/${{ env.REPO }}/runner:${{ env.IMAGE_TAG }}
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
bin/**
**/config.yaml

go.sum

# Others
.DS_Store
.vscode/**
Expand Down
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ FROM golang:1.20.4-alpine3.17 AS builder

RUN apk add --no-cache git openssh-client gcc libc-dev

# Setup SSH for private repo clone
COPY ./.ssh /root/.ssh
RUN git config --global url.git@github.com:.insteadOf https://github.com/

WORKDIR /app

COPY go.mod go.sum ./
Expand Down
Loading

0 comments on commit 4137a0a

Please sign in to comment.