-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: 👷 add github actions build/deploy
- Loading branch information
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.dockerignore | ||
Dockerfile | ||
.git | ||
.gitignore | ||
assets |
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
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" |
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
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 }}" }' |
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
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" ] |