Skip to content

Commit

Permalink
Update deploy.yml
Browse files Browse the repository at this point in the history
Signed-off-by: KhulnaSoft bot <[email protected]>
  • Loading branch information
khulnasoft-bot authored Oct 3, 2024
1 parent fb5747d commit 9e656c2
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: 'Deploy with Terraform'

on: workflow_dispatch

permissions:
packages: write
contents: read
permissions: read-all

jobs:
terraform:
Expand All @@ -17,22 +15,26 @@ jobs:

steps:
- name: Checkout
uses: actions/[email protected].2
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3.1.2
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd

- name: Authenticate to GitHub Container Registry
uses: docker/login-action@v2
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@62cf5bd3e4211a0a0b51f2c6d6a37129d828611d # v2.1.5
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} # Use PAT if necessary
project_id: ${{ secrets.GCP_PROJECT_ID }}
credentials_json: ${{ secrets.TF_GOOGLE_CREDENTIALS }}
export_environment_variables: true

- name: Build and push Docker image to GHCR
run: |
docker build -t ghcr.io/khulnasoft-lab/package-feeds/scheduled-feeds:latest .
docker push ghcr.io/khulnasoft-lab/package-feeds/scheduled-feeds:latest
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@f0990588f1e5b5af6827153b93673613abdc6ec7 # v2.1.1

- name: Configure gcloud
run: gcloud config set project ${{ secrets.GOOGLE_PROJECT_ID }}

- name: Generate the images for each feed
run: gcloud builds submit --tag gcr.io/${{ secrets.GOOGLE_PROJECT_ID }}/scheduled-feeds

- name: Terraform Init
run: terraform init
Expand All @@ -51,12 +53,12 @@ jobs:
run: terraform apply -auto-approve
working-directory: ./terraform

- name: Deploy to Cloud Run (using GHCR image)
- name: Deploy to Cloud Run
if: github.ref == 'refs/heads/main'
run: |
gcloud run deploy \
scheduled-feeds-srv \
--platform managed \
--region us-central1 \
--max-instances=1 \
--image ghcr.io/khulnasoft-lab/package-feeds/scheduled-feeds:latest;
--image gcr.io/${{ secrets.GOOGLE_PROJECT_ID }}/scheduled-feeds;

0 comments on commit 9e656c2

Please sign in to comment.