Skip to content

Commit

Permalink
ci: 👷 add github actions build/deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
vidhanio committed Jan 26, 2022
1 parent 2914127 commit 3ef67c3
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.dockerignore
Dockerfile
.git
.gitignore
assets
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
51 changes: 51 additions & 0 deletions .github/workflows/gce.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Deploy the Container to Google Compute Engine
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT }}
SERVICE: ${{ github.event.repository.name }}

on:
release:
types: [published]

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout the code from the repository
id: checkout
uses: actions/[email protected]

- name: Set up the Google Cloud SDK
id: setup-gcloud
uses: google-github-actions/[email protected]
with:
project_id: ${{ env.PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true

- name: Register Google Cloud SDK as a Docker credential helper
id: register-gcloud-docker
run: gcloud auth configure-docker

- name: Build the Docker image
id: build-image
run: docker build . -t gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}

- name: Publish the Docker image
id: publish-image
run: docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}

deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build

steps:
- name: Deploy to Google Compute Engine through a webhook
id: deploy-container
uses: joelwmale/[email protected]
with:
url: http://${{ secrets.WEBHOOK_IP }}:9000/hooks/deploy-${{ env.SERVICE }}
body: '{ "secret": "${{ secrets.WEBHOOK_SECRET }}" }'
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM golang:1.18-rc-alpine

WORKDIR /bot
COPY . .

RUN cd cmd/bot
RUN go build
CMD [ "./bot" ]

0 comments on commit 3ef67c3

Please sign in to comment.