From 9e656c22282175d0e8bc7f34ba3280ca18c8b5ea Mon Sep 17 00:00:00 2001 From: KhulnaSoft bot <43526132+khulnasoft-bot@users.noreply.github.com> Date: Fri, 4 Oct 2024 03:40:30 +0600 Subject: [PATCH] Update deploy.yml Signed-off-by: KhulnaSoft bot <43526132+khulnasoft-bot@users.noreply.github.com> --- .github/workflows/deploy.yml | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4f6fc7e..963511a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,9 +2,7 @@ name: 'Deploy with Terraform' on: workflow_dispatch -permissions: - packages: write - contents: read +permissions: read-all jobs: terraform: @@ -17,22 +15,26 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4.1.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 @@ -51,7 +53,7 @@ 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 \ @@ -59,4 +61,4 @@ jobs: --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;