feat: migrate to gcp #20
Workflow file for this run
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
name: "Deploy workflow" | |
on: | |
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: | |
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 |