-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: KhulnaSoft bot <[email protected]>
- Loading branch information
1 parent
fb5747d
commit 9e656c2
Showing
1 changed file
with
18 additions
and
16 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 |
---|---|---|
|
@@ -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/[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 | ||
|
@@ -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; |