Skip to content

Commit

Permalink
ci: deploy app to gcp
Browse files Browse the repository at this point in the history
  • Loading branch information
azazak123 committed Mar 4, 2024
1 parent f90e823 commit 595db98
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions .github/workflows/deploy-workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
name: "Deploy workflow"
on:
push:
branches:
- "master"
pull_request:

env:
PROJECT_ID: pure-feat-410619
REGION: europe
IMAGE_LOCATION: europe-docker.pkg.dev/pure-feat-410619/avatar-bot
IMAGE: avatar-bot:latest
SERVICE: avatar-bot

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: dprosper/[email protected]
with:
API_KEY: ${{ secrets.API_KEY }}
INSTALL_PLUGINS: cloud-functions
REGION: eu-de
- name: Setup ibmcloud
run: ibmcloud fn namespace target Avatar-bot
- name: Build static
run: nix build .#static
- name: Create actions
run: nix develop --command dune build @create-actions
- name: Redeploy
run: nix develop --command dune build @redeploy
credentials_json: ${{ secrets.SERVICE_ACCOUNT_KEY }}

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

- name: Docker auth
run: |
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
- name: Build image
run: |
nix build .#staticDocker
docker load --input result
docker tag ${{ env.IMAGE }} ${{ env.IMAGE_LOCATION }}/${{ env.IMAGE }}
- name: Push image
run: docker push ${{ env.IMAGE_LOCATION }}/${{ env.IMAGE }}

- name: Deploy to cloud run
run: |
gcloud run deploy ${{ env.SERVICE }} --region europe-west1 \
--image ${{ env.IMAGE_LOCATION }}/${{ env.IMAGE }} \
--set-env-vars=HOST=0.0.0.0 --set-secrets=BOT_TOKEN=BOT_TOKEN_PROD:latest \
--memory 128Mi --cpu 1 --max-instances 5

0 comments on commit 595db98

Please sign in to comment.